This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Exposing handle._callback and handle._args in asyncio
Type: enhancement Stage: resolved
Components: asyncio Versions: Python 3.6
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: gvanrossum, max, yselivanov
Priority: normal Keywords:

Created on 2017-02-01 21:51 by max, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (4)
msg286709 - (view) Author: Max (max) * Date: 2017-02-01 21:51
Is it safe to use the _callback and _args attributes of asyncio.Handle? Is it possible to officially expose them as public API?

My use case: 

    handle = event_loop.call_later(delay, callback)

    # this function can be triggered by some events
    def reschedule(handle):
      event_loop.call_later(new_delay, handle._callback, *handle._args)
      handle.cancel()
msg286714 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2017-02-01 22:08
> Is it safe to use the _callback and _args attributes of asyncio.Handle? Is it possible to officially expose them as public API?

I'd be -1 on exposing them.  Alternative asyncio event loop implementations such as uvloop don't have those attributes, and it's not always possible to add them.

> My use case:
>   def reschedule(handle):
>      event_loop.call_later(new_delay, handle._callback, *handle._args)
>      handle.cancel()

Why don't you just call `event_loop.call_later(delay, callback)`?
msg286719 - (view) Author: Max (max) * Date: 2017-02-01 23:02
@yselivanov I just wanted to use the handler to avoid storing the callback and args in my own data structure (I would just store the handlers whenever I may need to reschedule). Not a big deal, I don't have to use handler as a storage space, if it's not supported across implementations.
msg286724 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2017-02-02 00:20
> @yselivanov I just wanted to use the handler to avoid storing the callback and args in my own data structure (I would just store the handlers whenever I may need to reschedule). Not a big deal, I don't have to use handler as a storage space, if it's not supported across implementations.

Alright, closing the issue. Thanks!
History
Date User Action Args
2022-04-11 14:58:42adminsetgithub: 73601
2017-02-02 00:20:57yselivanovsetstatus: open -> closed
resolution: wont fix
messages: + msg286724

stage: resolved
2017-02-01 23:02:25maxsetmessages: + msg286719
2017-02-01 22:08:21yselivanovsetmessages: + msg286714
2017-02-01 21:51:35maxcreate