-
-
Notifications
You must be signed in to change notification settings - Fork 405
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Scalene process cannot be used in place of multiprocessing process #651
Comments
I think I located the problem: scalene/scalene/replacement_mp_lock.py Lines 18 to 30 in 31b9312
Since the class is nested in the function and does not have a getstate dunder, it can't be pickled. |
I believe this is fixed with 5e6982e. Please update to the latest version and try again! |
Did not work, same error still. |
scalene 1.5.26 |
|
I've moved the class out of the function; can you see if that helps? Thanks!
|
It doesn't work still. I am so confused. Maybe the version of my python may be different?
|
I just tested it and it's actually broken for a good reason; let me see what I can do. |
OK, I just pushed an update and tested it on Windows with your example program, and it worked! Please try again (as before, |
You can now just install this directly from the repo (I've merged the branch). |
OMG YES IT WORKSSSS |
Sorry, just reopened so this can be marked as completed when branch is merged |
Okay now there is a problem when profiling this code. from multiprocessing import Pool
def f(x):
return x * x
if __name__ == '__main__':
with Pool(processes=3) as pool:
for y in pool.imap_unordered(f, range(20)):
pass
|
By manually importing synchronize using Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\USER\AppData\Local\Programs\Python\Python311\Lib\multiprocessing\spawn.py", line 120, in spawn_main
exitcode = _main(fd, parent_sentinel)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\USER\AppData\Local\Programs\Python\Python311\Lib\multiprocessing\spawn.py", line 130, in _main
self = reduction.pickle.load(from_parent)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\USER\Documents\coding\.venv\Lib\site-packages\scalene\replacement_sem_lock.py", line 9, in _recreate_replacement_sem_lock
return ReplacementSemLock()
^^^^^^^^^^^^^^^^^^^^
TypeError: Lock.__init__() missing 1 required keyword-only argument: 'ctx'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\USER\AppData\Local\Programs\Python\Python311\Lib\multiprocessing\spawn.py", line 120, in spawn_main
exitcode = _main(fd, parent_sentinel)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\USER\AppData\Local\Programs\Python\Python311\Lib\multiprocessing\spawn.py", line 130, in _main
self = reduction.pickle.load(from_parent)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\USER\Documents\coding\.venv\Lib\site-packages\scalene\replacement_sem_lock.py", line 9, in _recreate_replacement_sem_lock
return ReplacementSemLock()
^^^^^^^^^^^^^^^^^^^^
TypeError: Lock.__init__() missing 1 required keyword-only argument: 'ctx'
...... |
OK, just pushed some more changes to the repo. Please try again (and thanks again for your patience!). |
I can confirm it works. Thanks for your help. |
Thanks again for your reports and your help in nailing down this issue! |
I'm still having a similar problem trying to profile my multiprocessing. No hurry, but any ideas?
|
Can you include more details? E.g., |
Describe the bug
I think Scalene tries to replace multiprocessing processes with its own. However, in doing so, it makes the project unable to pickle the functions
To Reproduce
Steps to reproduce the behavior:
scalene <filename>.py
Can't pickle <class 'scalene.replacement_mp_lock.replacement_mp_semlock.ReplacementSemLock'>: attribute lookup replacement_mp_semlock.ReplacementSemLock on scalene.replacement_mp_lock failed
Desktop (please complete the following information):
Windows 10
scalene==1.5.26
,cloudpickle==2.2.1
If you have not yet tried with the repository version (
python3 -m pip install git+https://github.com/plasma-umass/scalene
), please try that before reporting.Additional context
Full error:
OSError: [WinError 6] The handle is invalid
/EOFError: Ran out of input
The text was updated successfully, but these errors were encountered: