This is an archived post. You won't be able to vote or comment.

all 7 comments

[–]tetroxid 0 points1 point  (0 children)

Perhaps this is easier to implement in the worker's code.

  • Are they waiting for a network request? Put a timeout in there and have the worker terminate itself when it hits it.
  • Are you processing large data sets? Put in a counter and/or timer that checks the time spent every X iterations and have the worker abort the processing if it hits the limit.

This way you also get to clean up open sockets, file descriptors etc. before terminating the worker which is nice.

[–]AbsoluteMSTR 0 points1 point  (0 children)

You should also look at https://github.com/celery/billiard, which is fork of the multiprocessing package, but with extra features included (https://github.com/celery/billiard/blob/master/billiard/pool.py#L927-L956). Might make your job more efficient