Skip to content

@run_async decorator with functions with a third argument ? #123

@tgrondier

Description

@tgrondier

Hey, I'm having a bit of trouble using @run_async, here is my code snippet (I'm using the same architecture as in the updater_bot and installed the repository version):

    dp.addTelegramCommandHandler("akkarin", akkarin)

and:

@run_async
def akkarin(bot, update, args):
    pass

However when I send a command /akkarin, I get the following error in the console:

Exception in thread Thread-1:
Traceback (most recent call last):
  File "C:\Program Files\Python 3.5\lib\threading.py", line 923, in _bootstrap_inner
    self.run()
  File "C:\Program Files\Python 3.5\lib\threading.py", line 871, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Program Files\Python 3.5\lib\site-packages\telegram\dispatcher.py", line 39, in pooled
    result = func(*args, **kwargs)
TypeError: akkarin() missing 1 required positional argument: 'args'

I've tried fidling a bit with dispatcher.py to solve my problem, but to no avail due to my lack of knowledge; apparently, @run_async doesn't work with functions with an args argument. Is it a planned feature or is there a reason why it won't be implemented ?

Thank you for what you are doing, I had my own bot but this module just makes things that much easier, it takes less place and is easier to maintain :)

EDIT: I should note that this function works perfectly without the @run_async decoractor, it is just that it, you know, doesn't run asynchronously

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy