Skip to content

Implement a global lock#318

Draft
rwb27 wants to merge 3 commits intomainfrom
global-lock
Draft

Implement a global lock#318
rwb27 wants to merge 3 commits intomainfrom
global-lock

Conversation

@rwb27
Copy link
Copy Markdown
Collaborator

@rwb27 rwb27 commented Apr 22, 2026

This PR adds:

  • A server config key for the global lock
  • A class to implement the global lock
  • Context managers used when running actions or setting properties, to acquire said global lock
  • Arguments allowing actions or properties to opt out of the lock

Properties will either use the lock for setting, or not use the lock. If functional properties should use the lock for reading, they can acquire it in the getter.

No documentation yet, but there are some tests for the lock.

We still need

  • some tests of the lock in the context of properties and actions, including the argument to opt out.
  • tests in the context of a ThingServer and using a TestClient so it's running in a real event loop.
  • a way for a Thing to require global locking (e.g. a thing setting?) - that may be best done after we decide on Remove feature flags #316 .
  • documentation!

Closes #101

rwb27 added 3 commits April 22, 2026 15:34
This commit adds:
* A server config key for the global lock
* A class to implement the global lock
* Context managers used when running actions or setting properties, to acquire said global lock

Properties will either use the lock for setting, or not use the lock. If functional properties should use the lock for reading, they can acquire it in the getter.

No documentation yet, but there are some tests for the lock.

We still need some tests of the lock in the context of properties and actions, including the argument to opt out.
I've added tests for the ThingServerInterface functions related to the lock. This revealed a bug that is now fixed.

I also added a convenience function to mock Thing instances, which provides a few attributes that are needed by the various descriptors and should help keep test suites tidy.
@barecheck
Copy link
Copy Markdown

barecheck Bot commented Apr 23, 2026

Barecheck - Code coverage report

Total: 96.72%

Your code coverage diff: 0.08% ▴

Uncovered files and lines
FileLines
src/labthings_fastapi/actions.py510-511, 524, 549-550, 738, 909-910, 913, 916, 964
src/labthings_fastapi/properties.py484, 502, 582, 891, 895, 930-933, 1005, 1028, 1442
src/labthings_fastapi/server/__init__.py203, 217-220
src/labthings_fastapi/testing.py140, 268

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.

Not clear how to lock a thing?

1 participant