flying-circus / pyfilesystem

Automatically exported from code.google.com/p/pyfilesystem
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Race condition in PollingWatchableFS -- needs a lock #191

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. The callbacks self._on_path_modify, self._on_path_delete may be called in 
multiple threads -- both any thread using the filesystem as well as from the 
polling thread.
2. What will typically happen is a RuntimeError at 
https://code.google.com/p/pyfilesystem/source/browse/trunk/fs/watch.py#577 
'dictionary changed size during iteration'.

What is the expected output? What do you see instead?
It's a threading issue / race condition

What version of the product are you using? On what operating system?
0.5.0 linux

Please provide any additional information below.

I'm using a stripped-down version of the same class and added a lock -- 
threading.RLock -- around every use of self._path_info. That's my recommended 
solution.

Original issue reported on code.google.com by ulrik.sv...@gmail.com on 9 Dec 2014 at 9:14