cjnfuncs 2.4__tar.gz → 2.4.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cjnfuncs
3
- Version: 2.4
3
+ Version: 2.4.1
4
4
  Summary: A collection of core functions for tool script writing
5
5
  Author-email: Chris Nelson <github@cjnaz.com>
6
6
  License: MIT License
@@ -5,7 +5,9 @@ build-backend = "setuptools.build_meta"
5
5
 
6
6
  [project]
7
7
  name = "cjnfuncs"
8
- version = "2.4"
8
+ version = "2.4.1"
9
+ # 2.4.1 - resource_lock only init lock_info if not existing
10
+ # 2.4.1b1 - resource_lock only init lock_info if not existing
9
11
  # 2.4 - release
10
12
  # 2.4rc2 - check_path_exists() exception fix for unmounted network path (OSError: [Errno 19] No such device)
11
13
  # 2.4rc1 - doc fix on setuplogging()
@@ -46,6 +46,8 @@ process completes its work, and then acquire the I2C bus lock so that other proc
46
46
  - Resource locks are on the honor system. Any process can unget a lock, but should not if it didn't get the lock.
47
47
  - This lock mechanism is just as effective across threads within a process.
48
48
  - As many different/independent locks as needed may be created.
49
+ - The first time a lock is created (on the current computer since reboot) the lock info string (accessible via `get_lock_info()`)
50
+ is set to '', else it retains the value set by the most recent get_lock() call.
49
51
  - It is recommended (in order to avoid a minor memory leak) to `close()` the lock in the tool script cleanup code.
50
52
  Calling `close()` sets the `closed` attribute to True so that any following code can detect and re-instantiate the
51
53
  lock if needed.
@@ -90,10 +92,16 @@ checked and re-instantiate if needed.
90
92
  self.I_have_the_lock = False
91
93
  self.lock = posix_ipc.Semaphore(self.lockname, flags=posix_ipc.O_CREAT, mode=0o0600, initial_value=1)
92
94
 
93
- memory = posix_ipc.SharedMemory(self.lockname, flags=posix_ipc.O_CREAT, mode=0o0600, size=4096)
95
+ preexisting = False
96
+ try:
97
+ memory = posix_ipc.SharedMemory(self.lockname, flags=0)
98
+ preexisting = True
99
+ except posix_ipc.ExistentialError:
100
+ memory = posix_ipc.SharedMemory(self.lockname, flags=posix_ipc.O_CREAT, mode=0o0600, size=4096)
101
+
94
102
  self.mapfile = mmap.mmap(memory.fd, memory.size)
95
103
  os.close(memory.fd)
96
- if not self.is_locked():
104
+ if not preexisting:
97
105
  self._set_lock_info('')
98
106
 
99
107
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cjnfuncs
3
- Version: 2.4
3
+ Version: 2.4.1
4
4
  Summary: A collection of core functions for tool script writing
5
5
  Author-email: Chris Nelson <github@cjnaz.com>
6
6
  License: MIT License
File without changes
File without changes
File without changes
File without changes
File without changes