2.14.0 - new helpers.thread module + improved convert_datetime + fixes
-
privex.helpers.thread
(new module)-
Added
lock_acquire_timeout
context manager function, for acquiring locks onthreading.Lock
objects
using awith lock_acquire_timeout(lock)
context manager, allowing the use of a context manager, while still
being able to set a timeout / control blocking, plus the option to raise an exception on timeout. -
Added
BetterEvent
- a modified version ofthreading.Event
with more flexibility, such as the ability to
wait for "clear" state AND "set" state - not just "set" state. -
Added
StopperThread
- athreading.Thread
sub-class which comes with thread instance events allowing you
to signal a thread to stop/start/pause/unpause without having to constantly re-create stop/pause signalling. -
Added
SafeLoopThread
- based onStopperThread
, which is a looping thread with stop/pause signalling support,
along with two queue's pre-included on the instance:in_queue
for sending objects to the thread,
andout_queue
for receiving objects from the thread. -
Added
event_multi_wait
which allows for waiting on multiple thread Event's usingthreading.Event.wait
, and
some extra features if you pass Privex Helper'sBetterEvent
events instead of standard events.
-
-
privex.helpers.converters
convert_datetime
can now handledatetime.date
objects, and also attempts to fallback to converting
the passed object into a string and parsing the string result if it's not a supported type.- Added aliases
parse_datetime
andparse_date
forconvert_datetime
- Added aliases
parse_unixtime
,parse_epoch
andconvert_epoch_datetime
forconvert_unixtime_datetime
-
privex.helpers.exceptions
- Added
LockConflict
exception for failed attempts at acquiringthreading.Lock
orasyncio.Lock
objects. - Added
LockWaitTimeout
- a more specific sub-class ofLockConflict
for lock acquisition timeouts - Added
EventWaitTimeout
- for timeouts related tothreading.Event
- Added
-
Possibly some other minor changes
Unit Testing
-
Adjusted timing for
tests.cache.test_async_memcached
to avoid race condition test bug where sometimes
it would take too long to get the cache item to update it, and result in the item expiring before it can
be updated. -
Added more unit tests to
test_converters
- Test
convert_datetime
handling ofdatetime.date
objects - Test
convert_datetime
handling of byte-strings - Test
convert_datetime
handling of just string dates without times
- Test
-
Added new
test_thread
module which tests a good portion of the newprivex.helpers.thread
module.