tractor
tractor copied to clipboard
Task sychronization func decorator
After working on the built-in pubsub system I've realized it may be useful to have a (set of) synchronization decorator(s) for limiting multi-task access to user defined functions. This would make it easy to allow for multiple actors to make calls to a common actor that defines functions which don't want more then some finite number of tasks executing its body at a given time.
Need to think about it a little more.
which don't want more then some finite number of tasks executing its body at a given time.
Example?
See the test here, though this was a pretty old example at this point and taking a much different approach then we can now with the stuff from #209.
@tractor.msg.pub(tasks=['one', 'two'])
async def multilock_pubber(get_topics):
yield {'doggy': 10}
The basic idea was you could call (Portal.run()) this target func multiple times but in the "server" actor only one task would ever run the number of tasks specified (possibly by name?). I'm not sure if this makes sense any more at all since the func can just be defined to use trio.Locks and the like (trio.CapacityLimiter?).
This may have been a chewing the fat issues 😂
Yah so I think the basic idea was having multiple tasks which were seeded differently maybe?
We might be able to just kill this one for now.