Question about threading.RLock

20 views
Skip to first unread message

juko...@gmail.com

unread,
Apr 2, 2018, 12:18:28 PM4/2/18
to nameko-dev
Hi,

I'm using a package that makes use of `threading.RLock` internally (PyFilesystem2).

The lock is used to prevent multiple threads from accessing an opened filesystem, which makes sense. But I don't want it to do that for some specific operations (I'm already ensuring operations are atomic).

So I am wondering if/how Nameko reacts to or is affected by `threading.RLock` locks. Because if it isn't (my hope!) then I can parallelize my operations by leveraging Nameko, rather than hacking PyFilesystem2 :)

Thanks in advance for your help :)

Geoff

Matt Yule-Bennett

unread,
Apr 3, 2018, 4:02:46 AM4/3/18
to nameko-dev
I'm pretty sure Eventlet will patch the lock, so it will apply inside Nameko.

juko...@gmail.com

unread,
Apr 3, 2018, 3:21:21 PM4/3/18
to nameko-dev
Hi Matt,

Any thoughts about the level at which it might apply? i.e. I expect it to apply within a worker context, but not between workers.

Geoff

matt.b...@student.com

unread,
Apr 4, 2018, 7:34:23 AM4/4/18
to nameko-dev
I would certainly test this rather than making assumptions, but I imagine it will behave in the way the docs describe, applied to the eventlet threads.

Each worker is its own thread and should be able to use the "re-entrant" properties of the lock (i.e. a single worker can acquire it multiple times), but while locked no other thread, worker or otherwise, will be able to acquire it.
Reply all
Reply to author
Forward
0 new messages