3 ms·
I haven't use Python multiprocessing packages, so I need to ask, how does one do flexible work queues with them? I mean a situation like where in threaded cont
by _flux 3y ago
I haven't use Python multiprocessing packages, so I need to ask, how does one do flexible work queues with them?
I mean a situation like where in threaded context there would be code like:
def determine_quest_latency(quest_name: str) -> int:
return other_thread.wait_sync_job(lambda context: context.ping_quest(quest_name))
..without needing to provide a protocol that covers each possible scenario the client might wish to execute in the process?
I believe the answer is "you don't", but passing functions in messages is a highly convenient way to structure code in a way that local decisions can stay local, instead of being interspersed around the codebase.
- xmcqdpt2 3y agoI believe you just pass objects instead, like you would in OOP, and take the hit of pickling and unpickling them every time. If you really want to pass lambdas, you can use a third party library to pickle them https://github.com/cloudpipe/cloudpickle https://github.com/cloudpipe/cloudpickle Yes, this is not great.