singleton.py misdesign #775

Closed
opened 2015-02-02 21:34:20 +01:00 by Ignalion · 0 comments
Ignalion commented 2015-02-02 21:34:20 +01:00 (Migrated from github.com)

Hello

I just had a little overview to the project and found the file singleton.py with singleinstance class especially.

The design of this class is incorrect because of two things as below:

  1. This class has to ensure that lock file is being deleted when app is closed (as far as I understand it). But it won't work. Well, it would, probably, but as it's stated in python doc, it's not guaranteed that __del__ method will ever called. So it can easily lead to situation when lock file remains in system after app shutdown.
  2. There is try..except block in __del__ method which would not work ever because, as stated in python doc, any exception that occurs while running __del__ method will be ignored and just printed a warning in stderr instead.

Thus, I'd suggest to either make some other method like release() that should be called directly or redesign this class\idea.

Thanks,
Constantine

Hello I just had a little overview to the project and found the file [singleton.py](https://github.com/Bitmessage/PyBitmessage/blob/master/src/singleton.py) with singleinstance class especially. The design of this class is incorrect because of two things as below: 1. This class has to ensure that lock file is being deleted when app is closed (as far as I understand it). But it won't work. Well, it would, probably, but as it's stated in python doc, it's not guaranteed that `__del__` method will ever called. So it can easily lead to situation when lock file remains in system after app shutdown. 2. There is `try..except` block in `__del__` method which would not work ever because, as stated in python doc, any exception that occurs while running `__del__` method will be ignored and just printed a warning in stderr instead. Thus, I'd suggest to either make some other method like `release()` that should be called directly or redesign this class\idea. Thanks, Constantine
This repo is archived. You cannot comment on issues.
No Milestone
No project
No Assignees
1 Participants
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: Bitmessage/PyBitmessage-2024-12-22#775
No description provided.