2.14.0 - new helpers.thread module + improved convert_datetime + fixes
-
privex.helpers.thread(new module)-
Added
lock_acquire_timeoutcontext manager function, for acquiring locks onthreading.Lockobjects
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.Eventwith more flexibility, such as the ability to
wait for "clear" state AND "set" state - not just "set" state. -
Added
StopperThread- athreading.Threadsub-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_queuefor sending objects to the thread,
andout_queuefor receiving objects from the thread. -
Added
event_multi_waitwhich allows for waiting on multiple thread Event's usingthreading.Event.wait, and
some extra features if you pass Privex Helper'sBetterEventevents instead of standard events.
-
-
privex.helpers.convertersconvert_datetimecan now handledatetime.dateobjects, 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_datetimeandparse_dateforconvert_datetime - Added aliases
parse_unixtime,parse_epochandconvert_epoch_datetimeforconvert_unixtime_datetime
-
privex.helpers.exceptions- Added
LockConflictexception for failed attempts at acquiringthreading.Lockorasyncio.Lockobjects. - Added
LockWaitTimeout- a more specific sub-class ofLockConflictfor 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_memcachedto 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_datetimehandling ofdatetime.dateobjects - Test
convert_datetimehandling of byte-strings - Test
convert_datetimehandling of just string dates without times
- Test
-
Added new
test_threadmodule which tests a good portion of the newprivex.helpers.threadmodule.