-
Notifications
You must be signed in to change notification settings - Fork 70
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
Task which Triggers Multiprocessing #82
Comments
I am kinda answering my question, although not completely satisfied. I manage to start a multithreading task with dango-chroniker by using the mysterious and undocumented |
I'm not sure what you mean. All chroniker jobs are run in separate threads
by default.
On Apr 19, 2017 6:06 PM, "Diego F Coêlho" <[email protected]> wrote:
I am kinda answering my question, although not completely satisfied.
I manage to start a multithreading task with dango-chroniker by using the
mysterious and undocumented
from multiprocessing.pool import ThreadPool but still no success with true
multiprocess.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#82 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAHHl-E4GJ-6Q81qlCy990tChSED2I0rks5rxoVVgaJpZM4M2WvF>
.
|
I meant that I wanted to start a multiprocessing task using chroniker but the processes shuts after no activity is performed. Although a multithread was possible using the library I described previsouly, it wasn't possible using the standard library and multiprocessing (true isolated processes) can't work anyhow.. |
You need to give me a little more detail about how you're "starting a multiprocessing task", because that could mean almost anything. Like I said, all jobs are run as a separate process, so you don't need to do any more work than just implement your Django management command. If you're using nohup or screen or some other method to launch a process, it might be happening. However, the chroniker job won't track those and will immediately return after the process launches. |
I am afraid I can not provide a piece of working code as a perfect representation of what I was intending but following the examples on Python Docs, I could use the code below:
Then the chroniker thread/process would stay up until the processes finished and even if we don't bother to get messages from the standalone process, it should be executed. The closest it gets can be seen in the code below:
But its execution triggers:
BTW, there are a few things on chroniker that bothers me a bit and would like to show you.. Should I open a issue for each or a all-in-one? With a some instructions I can try to cooperate with the project but I have no idea how a python environment setup for that would be.. |
Thanks for the detail. That's interesting. In general, I don't see why that wouldn't work. The error you're getting is because the new process is trying to access Django settings, but doesn't have the right path and/or Django settings module name set. And by all means, feel free to open issues for any bugs or design issues you see. The way I resolve bugs is to reproduce the error in a unittest, which would be called like:
and then fix the issue and confirm the test passes. However, bugs involving multiprocessing can be tricky to fix because Django's test runner has a built-in transaction which only works from the main process, so trying to access any Django tables or settings in processes outside of that will get you strange errors like the one you reported. |
Is it possible to trigger a multiprocessing task? I tried but run it as a django management command makes it finish with no fail (and also no task performed) after a few seconds.
The text was updated successfully, but these errors were encountered: