Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python3. Async hook doesn't seem to work #240

Closed
peppelinux opened this issue Jun 14, 2017 · 1 comment
Closed

Python3. Async hook doesn't seem to work #240

peppelinux opened this issue Jun 14, 2017 · 1 comment

Comments

@peppelinux
Copy link

peppelinux commented Jun 14, 2017

According to the documentation I tryed first of all this configuration, considering that I placed that hook function in the same file and, as you can read later, in the file called hooks.py in its working directory:

tid = async('subprocess.run', 
                ['bash', '/tmp/test.sh', 'test'], 
                stdout=PIPE, 
                task_name='example-{}'.format(uuid4().hex),
                hook='hooks.hook_example' # optional, run action when result will be available
                )

This way it returns, as I can read from stdout:

[Q] ERROR malformed return hook 'hooks.hook_example' for [example-a4b92b55f392441d8fee85f22c5311d3]

So I placed that hooks, in the async init, as an callable object (not a string):

    import application_name.hooks
    tid = async('subprocess.run', 
                ['bash', '/tmp/test.sh', 'test'], 
                stdout=PIPE, 
                task_name='example-{}'.format(uuid4().hex),
                hook=application_name.hooks.hook_example # optional, run action when result will be available
                )

It doesn't notify any errors or warning, this way it should be executed succesfully but... But nothing was called, I put a file creation in a temporary folder to be sure that it was called or not.

So, I think it could be usefull having these:

django.VERSION = (1, 10, 7, 'final', 0)
sys.version           = '3.5.2 (default, Nov 17 2016, 17:05:23) \n[GCC 5.4.0 20160609]'
django-q (0.8.0)
@peppelinux peppelinux changed the title Python3. Async hook doesn't seems to work Python3. Async hook doesn't seem to work Jun 14, 2017
@peppelinux
Copy link
Author

Fixed, my mistake:

According to signals.py I read that the hook declaration inside async(**kwargs) must be as a string BUT the namespace of this must be very accurate.

I fixed this in this way, specifing the application_name.file_name.funcion_name as a string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant