On Sat, Aug 9, 2014 at 4:35 AM, Neil D. Cerutti wrote:
> Doesn't any natural looking use of blocking=False suffer from the same race
> condition? What's the correct way to use it?
Actually, I don't know. I try to avoid any form of thread locking
where possible, and I don't remember the last time
On Fri, Aug 8, 2014 at 7:25 AM, Ethan Furman wrote:
> On 08/08/2014 04:51 AM, cool-RR wrote:
>>
>>
>> If I want to acquire a `threading.Lock` using the context manager
>> protocol,
>> is it possible to specify the `blocking` and `timeout` arguments that
>> `acquire` would usually take?
>
>
> Not
On Fri, Aug 8, 2014 at 11:35 AM, Neil D. Cerutti wrote:
> On 8/8/2014 12:16 PM, Chris Angelico wrote:
>
>> On Sat, Aug 9, 2014 at 2:05 AM, Neil D. Cerutti
>> wrote:
>>
>>> Perhaps defer release, a la a common Go pattern:
>>>
>>> with contextlib.ExitStack() as stack:
>>> acquired = lock.acqu
On 8/8/2014 2:35 PM, Neil D. Cerutti wrote:
Here's another attempt at context managing:
@contextlib.contextmanager
def release_if_acquired(lock, blocking=True, timeout=-1):
acquired = lock.acquire(blocking, timeout)
if acquired:
yield acquired
lock.release()
e
On 8/8/2014 12:16 PM, Chris Angelico wrote:
On Sat, Aug 9, 2014 at 2:05 AM, Neil D. Cerutti wrote:
Perhaps defer release, a la a common Go pattern:
with contextlib.ExitStack() as stack:
acquired = lock.acquire(blocking=False)
if acquired:
stack.callback(lock.release)
On Sat, Aug 9, 2014 at 2:05 AM, Neil D. Cerutti wrote:
> Perhaps defer release, a la a common Go pattern:
>
> with contextlib.ExitStack() as stack:
> acquired = lock.acquire(blocking=False)
> if acquired:
> stack.callback(lock.release)
> do_stuff
There's a race condition i
On 8/8/2014 9:25 AM, Ethan Furman wrote:
On 08/08/2014 04:51 AM, cool-RR wrote:
If I want to acquire a `threading.Lock` using the context manager
protocol,
is it possible to specify the `blocking` and `timeout` arguments that
`acquire` would usually take?
Not that I know of, but why would y
On 08/08/2014 04:51 AM, cool-RR wrote:
If I want to acquire a `threading.Lock` using the context manager protocol,
is it possible to specify the `blocking` and `timeout` arguments that
`acquire` would usually take?
Not that I know of, but why would you want to? There's no built-in 'if' with
Hi all,
If I want to acquire a `threading.Lock` using the context manager protocol, is
it possible to specify the `blocking` and `timeout` arguments that `acquire`
would usually take?
Thanks,
Ram.
--
https://mail.python.org/mailman/listinfo/python-list