tractor icon indicating copy to clipboard operation
tractor copied to clipboard

Task sychronization func decorator

Open goodboy opened this issue 6 years ago • 3 comments

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.

goodboy avatar Jan 20 '19 19:01 goodboy

which don't want more then some finite number of tasks executing its body at a given time.

Example?

gc-ss avatar May 13 '21 05:05 gc-ss

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 😂

goodboy avatar May 13 '21 12:05 goodboy

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.

goodboy avatar May 13 '21 12:05 goodboy