dispy icon indicating copy to clipboard operation
dispy copied to clipboard

Create temporary directory per user?

Open jonasc opened this issue 8 years ago • 6 comments

I just stumbled upon the file structure and thought about what will happen if two users run dispy on the same machine. If I understand correctly you create /tmp/dispy/node and set it's access right to 700 so no other user is allowed to see or even write into this directory.

If this is correct, a second user trying to run dispynode will get this message (just tested):

Traceback (most recent call last):
  File "/home/test/.virtualenvs/dispy/bin/dispynode.py", line 1719, in <module>
    _dispy_node = _DispyNode(**_dispy_config)
  File "/home/test/.virtualenvs/dispy/bin/dispynode.py", line 302, in __init__
    with open(os.path.join(self.dest_path_prefix, 'config'), 'wb') as fd:
PermissionError: [Errno 13] Permission denied: '/tmp/dispy/node/config'

Wouldn't it be better to create e.g. /tmp/dispy_<username>/node or /tmp/dispy/<username>/node?

jonasc avatar Jul 10 '16 15:07 jonasc

A node should run only one instance of dispynode, as it assumes it can schedule all processors available. If another instance runs simultaneously, they can over-schedule processors. Ideally file locking should be used to prevent multiple instances, but not sure how easy / portable it is for multiple architectures.

I am curious to know use case where different users want to run dispynode simultaneously? It may be possible to setup paths as you suggest (or perhaps /tmp/dispy/node// where is process id of dispynode).

pgiri avatar Jul 10 '16 15:07 pgiri

Your explanation sounds reasonable. However I think this might come on in Situations like mine: I'm using various university computers as dispynodes to speed up some computations. If someone else has the same idea they could use the nodes I set up but they might not for (at least) two reasons:

  1. I protect the nodes with authentification or ssl.
  2. They do not want to run computations on nodes not under their control.

In the end they might set up nodes themselves with differing port numbers.

jonasc avatar Jul 10 '16 17:07 jonasc

Multiple instances of dispynode can be run by specifying different ports and different --dest_path_prefix options. While it is more cumbersome to use --dest_path_prefix, it may prevent accidental "abuse". May be the right thing is to provision portion of processors in each instance (e..g., user 1 uses 1/4 of available processors, user 2 remaining etc.)? I think this shouldn't interfere with rest of dispy, other than probably some spurious warning messages about user 1's client not being able to use user 2's server etc.

pgiri avatar Jul 10 '16 19:07 pgiri

I guess, since it is no real issue for me now and was rather just thinking theoretically about it, you could just leave it as is. If someone stumbles across this issue they might also have some sensible ideas on how to solve.

jonasc avatar Jul 10 '16 22:07 jonasc

I ran into the described problem. I told a colleague about dispy and he tried in on one of our machines. He stopped is test but the folder /tmp/dispy/ was created for him. This rendered me unable to use that machine for my instance of dispynode.py.

I believe dispy should create folders in /tmp/ with an appended random string or something (like most other software does to handle this kind of problem). Maybe the temporary directory should be created with this function: https://docs.python.org/3.6/library/tempfile.html#tempfile.mkdtemp

yschroeder avatar Mar 13 '17 13:03 yschroeder

Same problem arises when running dispyscheduler.

yschroeder avatar Mar 16 '17 15:03 yschroeder