Skip to content

Conversation

@PrzemekWirkus
Copy link
Contributor

@PrzemekWirkus PrzemekWirkus commented Jul 19, 2016

Description

On RP2 Linux we have a deadlock when using root account so we may want to drop mocking feature but have non-blocking mbed-ls with timeout=.5 sec on file lock acquire.

Rationale

To catch LockTImeout exception we can't use context mgr. We need to use explicit
calls to acquire(timeout=1) and release() to catch timeout.
Timeout may occur on some Resource Managers instance.

LockFile objects support the context manager protocol used by the statement:with
statement. The timeout option is not supported when used in this fashion. While
support for timeouts could be implemented, there is no support for handling the
eventual Timeout exceptions raised by the enter() method, so you would have
to protect the with statement with a try statement. The resulting construct
would not be any simpler than just using a try statement in the first place.

Example timeout

mbedls
error: Timeout waiting to acquire lock for /home/pi/.mbed-ls/mbedls-lock
+---------------+----------------------+-------------+--------------+--------------------------------------------------+-----------------+
| platform_name | platform_name_unique | mount_point | serial_port  | target_id                                        | daplink_version |
+---------------+----------------------+-------------+--------------+--------------------------------------------------+-----------------+
| NRF51_DK      | NRF51_DK[0]          | /mnt/MBED__ | /dev/ttyACM2 | 1100021944203120324C46383030343239303038B9C6DFD8 | 0219            |
| NRF51_DK      | NRF51_DK[1]          | /mnt/MBED_  | /dev/ttyACM1 | 1100021944203120324C46383130383131323033B9C6DFD8 | 0219            |
+---------------+----------------------+-------------+--------------+--------------------------------------------------+-----------------+

To catch LockTImeout exception we can't use context mgr. We need to use explicit
calls to acquire(timeout=1) and release() to catch timeout.
TImeout may occur on some Resource Managers instance.

LockFile objects support the context manager protocol used by the statement:with
statement. The timeout option is not supported when used in this fashion. While
support for timeouts could be implemented, there is no support for handling the
eventual Timeout exceptions raised by the __enter__() method, so you would have
to protect the with statement with a try statement. The resulting construct
would not be any simpler than just using a try statement in the first place.
@PrzemekWirkus
Copy link
Contributor Author

@bridadan @adbridge @mazimkhan FYI

@PrzemekWirkus PrzemekWirkus merged commit e80b5ee into master Jul 19, 2016
@theotherjimmy theotherjimmy deleted the devel_lockfile_timeout branch September 27, 2017 22:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants