You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 on `threading.Lock` objects
using a `with 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 of `threading.Event` with more flexibility, such as the ability to
wait for "clear" state AND "set" state - not just "set" state.
- Added `StopperThread` - a `threading.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 on `StopperThread`, 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,
and `out_queue` for receiving objects from the thread.
- Added `event_multi_wait` which allows for waiting on multiple thread Event's using `threading.Event.wait`, and
some extra features if you pass Privex Helper's `BetterEvent` events instead of standard events.
- `privex.helpers.converters`
- `convert_datetime` can now handle `datetime.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` and `parse_date` for `convert_datetime`
- Added aliases `parse_unixtime`, `parse_epoch` and `convert_epoch_datetime` for `convert_unixtime_datetime`
- `privex.helpers.exceptions`
- Added `LockConflict` exception for failed attempts at acquiring `threading.Lock` or `asyncio.Lock` objects.
- Added `LockWaitTimeout` - a more specific sub-class of `LockConflict` for lock acquisition timeouts
- Added `EventWaitTimeout` - for timeouts related to `threading.Event`
- 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 of `datetime.date` objects
- Test `convert_datetime` handling of byte-strings
- Test `convert_datetime` handling of just string dates without times
- Added new `test_thread` module which tests a good portion of the new `privex.helpers.thread` module.
0 commit comments