-
Notifications
You must be signed in to change notification settings - Fork 48
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
getting the pid of the process #100
Comments
Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
Thank you for responding) def update_tasks(self):
"""Handles timing out Tasks."""
for task in self.task_manager.timeout_tasks():
self.task_manager.task_done(
task.id, TimeoutError("Task timeout", task.timeout))
self.worker_manager.stop_worker(task.worker_id)
for task in self.task_manager.cancelled_tasks():
self.task_manager.task_done(
task.id, CancelledError())
self.worker_manager.stop_worker(task.worker_id) You write the def update_tasks(self):
"""Handles timing out Tasks."""
for task in self.task_manager.timeout_tasks():
self.task_manager.task_done(
task.id, TimeoutError("Task timeout", task.timeout, task.worker_id, task.id))
self.worker_manager.stop_worker(task.worker_id)
for task in self.task_manager.cancelled_tasks():
self.task_manager.task_done(
task.id, CancelledError())
self.worker_manager.stop_worker(task.worker_id) thus, intercepting an exception, it will not be difficult to find out the pid of the process and the number of the task for which this exception occurred. I propose to do the same in the case of raise Exception in task. Thanks! |
Hello, it is not possible to add the PID to all exceptions. Only error we can add the PID to is What is the use case you have in mind? Why do you need the worker PID? This is internal information and should not be of concern to the user. |
I agree to the worker_id account. Perhaps this information will be superfluous. But task_id is useful, for example, to understand which tasks have not worked. I think this is a frequent request |
The If you want to understand which submission worked and which didn't, you can use the ID of the In [4]: future = p.schedule(example)
In [5]: id(future)
Out[5]: 140154882138608 The future is always the same object even when passed to callbacks. In [6]: def done_callback(future):
...: print(id(future))
In [7]: future.add_done_callback(done_callback)
140154882138608 Any attribute you will add to the In [1]: import pebble
In [2]: p = pebble.ProcessPool()
In [3]: def done_callback(future):
...: print(future.function)
...: print(future.args)
In [4]: def my_function(arg1, arg2):
...: return 1
In [5]: future = p.schedule(my_function, args=[1, 2])
In [7]: future.function = my_function
In [8]: future.args = [1, 2]
In [9]: future.add_done_callback(done_callback)
<function my_function at 0x7fd7f3bf2820>
[1, 2] |
Closing this issue due to lack of response. Please re-open if you require further clarifications. |
Greetings!
is it possible to get the pid of a process that terminates with timeoutError in ProcessPool() class?
The text was updated successfully, but these errors were encountered: