[Solved] Python multitasking strict app fails: SEMAPHORE


#1

Git Repository

Everything works except the actual function which needs the Multiprocessing library.

  File "/snap/ftpscan/x1/usr/lib/python3.6/multiprocessing/synchronize.py", line 162, in __init__
    SemLock.__init__(self, SEMAPHORE, 1, 1, ctx=ctx)
  File "/snap/ftpscan/x1/usr/lib/python3.6/multiprocessing/synchronize.py", line 59, in __init__
    unlink_now)
PermissionError: [Errno 13] Permission denied

I’ve found some info about preloading but this does not help and the project looks abandoned.

Should I file a bug or is there a workaround (or am I doing something wrong?)


#2

This is discussed in Python multiprocessing sem_open blocked in strict mode


#3

Yes, I found and linked to the git repo posted in that thread. However, it the preload does not work for me. Even puling directly from the pullrequest diddledan created does not work.


#4

I had a similar problem. I believe i had to include python in my command section. Something like:

command: bin/snapcraft-preload /usr/bin/python $SNAP/bin/ftpscan


#5
snapcraft-ftpscan # ftpscan 10.0.1.0/24 anders pass
Traceback (most recent call last):
  File "/snap/ftpscan/x1/bin/ftpscan", line 11, in <module>
    load_entry_point('ftpscan==1.0', 'console_scripts', 'ftpscan')()
  File "/snap/ftpscan/x1/lib/python3.6/site-packages/ftpscan.py", line 39, in main
    result = multiprocessor(attempt_ftp_login, target_list, workers)
  File "/snap/ftpscan/x1/lib/python3.6/site-packages/ftpscan.py", line 61, in multiprocessor
    p = Pool(processes=workers)
  File "/usr/lib/python3.6/multiprocessing/context.py", line 119, in Pool
    context=self.get_context())
  File "/usr/lib/python3.6/multiprocessing/pool.py", line 157, in __init__
    self._setup_queues()
  File "/usr/lib/python3.6/multiprocessing/pool.py", line 271, in _setup_queues
    self._inqueue = self._ctx.SimpleQueue()
  File "/usr/lib/python3.6/multiprocessing/context.py", line 112, in SimpleQueue
    return SimpleQueue(ctx=self.get_context())
  File "/usr/lib/python3.6/multiprocessing/queues.py", line 315, in __init__
    self._rlock = ctx.Lock()
  File "/usr/lib/python3.6/multiprocessing/context.py", line 67, in Lock
    return Lock(ctx=self.get_context())
  File "/usr/lib/python3.6/multiprocessing/synchronize.py", line 162, in __init__
    SemLock.__init__(self, SEMAPHORE, 1, 1, ctx=ctx)
  File "/usr/lib/python3.6/multiprocessing/synchronize.py", line 59, in __init__
    unlink_now)
PermissionError: [Errno 13] Permission denied
snapcraft-ftpscan # 

Same issue I’m afraid, but thanks.


#6

Did you use diddledan’s semaphore-support branch? This actually worked for me.

    source: https://github.com/diddledan/snapcraft-preload.git
    source-branch: semaphore-support

#7

No I did not ;)…

I tried that on the original repo but that had no semaphore-support branch (of course), then it slipped my mind on diddledan’s fork.

Thanks! It works! (its not necessary to prepend /usr/bin/python)