Re: [Async-sig] "read-write" synchronization

2017-06-25 Thread Yarko Tymciurak
On Sun, Jun 25, 2017 at 10:33 PM, Guido van Rossum wrote: > On Sun, Jun 25, 2017 at 3:38 PM, Yarko Tymciurak > wrote: > >> To be a well-behaved (capable of effective cooperation) task in such a >> system, you should guard against getting embroiled in

Re: [Async-sig] "read-write" synchronization

2017-06-25 Thread Yarko Tymciurak
On Sun, Jun 25, 2017 at 10:46 PM, Yarko Tymciurak wrote: > > > On Sun, Jun 25, 2017 at 10:33 PM, Guido van Rossum > wrote: > >> On Sun, Jun 25, 2017 at 3:38 PM, Yarko Tymciurak >> wrote: >> >>> To be a well-behaved (capable of

Re: [Async-sig] "read-write" synchronization

2017-06-25 Thread Guido van Rossum
On Sun, Jun 25, 2017 at 3:38 PM, Yarko Tymciurak wrote: > To be a well-behaved (capable of effective cooperation) task in such a > system, you should guard against getting embroiled in potentially blocking > I/O tasks whose latency you are not able to control (within

Re: [Async-sig] "read-write" synchronization

2017-06-25 Thread Chris Jerdonek
So here's one approach I'm thinking about for implementing readers-writer synchronization. Does this seem reasonable as a starting point, or am I missing something much simpler? I know there are various things you can prioritize for (readers vs. writers, etc), but I'm less concerned about those

Re: [Async-sig] "read-write" synchronization

2017-06-25 Thread Yarko Tymciurak
On Sun, Jun 25, 2017 at 4:54 PM Chris Jerdonek wrote: > The read-write operations I'm protecting will have coroutines inside > that need to be awaited on, so I don't think I'll be able to take > advantage to that extreme. > > But I think I might be able to use your

Re: [Async-sig] "read-write" synchronization

2017-06-25 Thread Chris Jerdonek
On Sun, Jun 25, 2017 at 3:09 PM, Nathaniel Smith wrote: > On Sun, Jun 25, 2017 at 2:13 PM, Chris Jerdonek > wrote: >> I'm using asyncio, and the synchronization primitives that asyncio >> exposes are relatively simple [1]. Have options for async

Re: [Async-sig] "read-write" synchronization

2017-06-25 Thread Nathaniel Smith
On Sun, Jun 25, 2017 at 2:13 PM, Chris Jerdonek wrote: > I'm relatively new to async programming in Python and am thinking > through possibilities for doing "read-write" synchronization. > > I'm using asyncio, and the synchronization primitives that asyncio > exposes are

Re: [Async-sig] "read-write" synchronization

2017-06-25 Thread Guido van Rossum
The secret is that as long as you don't yield no other task will run so you don't need locks at all. On Jun 25, 2017 2:24 PM, "Chris Jerdonek" wrote: > Thank you. I had seen that, but it seems heavier weight than needed. > And it also requires locking on reading. > >

Re: [Async-sig] "read-write" synchronization

2017-06-25 Thread Chris Jerdonek
The read-write operations I'm protecting will have coroutines inside that need to be awaited on, so I don't think I'll be able to take advantage to that extreme. But I think I might be able to use your point to simplify the logic a little. (To rephrase, you're reminding me that context switches

Re: [Async-sig] "read-write" synchronization

2017-06-25 Thread Chris Jerdonek
Thank you. I had seen that, but it seems heavier weight than needed. And it also requires locking on reading. --Chris On Sun, Jun 25, 2017 at 2:16 PM, Andrew Svetlov wrote: > There is https://github.com/aio-libs/aiorwlock > > On Mon, Jun 26, 2017 at 12:13 AM Chris

Re: [Async-sig] "read-write" synchronization

2017-06-25 Thread Andrew Svetlov
There is https://github.com/aio-libs/aiorwlock On Mon, Jun 26, 2017 at 12:13 AM Chris Jerdonek wrote: > I'm relatively new to async programming in Python and am thinking > through possibilities for doing "read-write" synchronization. > > I'm using asyncio, and the

[Async-sig] "read-write" synchronization

2017-06-25 Thread Chris Jerdonek
I'm relatively new to async programming in Python and am thinking through possibilities for doing "read-write" synchronization. I'm using asyncio, and the synchronization primitives that asyncio exposes are relatively simple [1]. Have options for async read-write synchronization already been