Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test and improve the synchronization code #209

Merged

Conversation

kurtmckee
Copy link
Contributor

Added

  • Add tests to bring Synchronization.py to 100% coverage
  • Add type annotations to the synchronization primitives
  • Add typing_extensions as a Python 3.9 requirement; this is needed to annotate that the synchronized() decorator takes a function with a certain set of parameter and return types and returns a function with the same parameter and return types

Changed

  • Make the synchronized function's self parameter explicit; this allows the self parameter to be type-annotated so the dependency on the self.mutex attribute is explicit
  • Use the self.mutex lock as a context manager
  • Support keyword arguments to synchronized functions

Fixed

  • Wrap synchronized functions correctly; previous behavior was to lose the function name and docstring

Removed

  • Remove print() lines that are commented out
  • Remove a bytes instance check; method names can only be strings

Added
-----

* Add tests to bring `Synchronization.py` to 100% coverage
* Add type annotations to the synchronization primitives
* Add `typing_extensions` as a Python 3.9 requirement;
  this is needed to annotate that the `synchronized()` decorator
  takes a function with a certain set of parameter and return types
  and returns a function with the same parameter and return types

Changed
-------

* Make the synchronized function's `self` parameter explicit;
  this allows the `self` parameter to be type-annotated
  so the dependency on the `self.mutex` attribute is explicit
* Use the `self.mutex` lock as a context manager
* Support keyword arguments to synchronized functions

Fixed
-----

* Wrap synchronized functions correctly;
  previous behavior was to lose the function name and docstring

Removed
-------

* Remove `print()` lines that are commented out
* Remove a `bytes` instance check; method names can only be strings
@coveralls
Copy link

coveralls commented Oct 13, 2024

Coverage Status

coverage: 64.919% (+0.3%) from 64.591%
when pulling d984eec on kurtmckee:test-synchronization
into f162aa2 on LudovicRousseau:master.

@LudovicRousseau LudovicRousseau merged commit 0186f21 into LudovicRousseau:master Oct 14, 2024
25 checks passed
@LudovicRousseau
Copy link
Owner

Thanks

@kurtmckee kurtmckee deleted the test-synchronization branch October 14, 2024 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants