Skip to content

Commit

Permalink
Don't reraise exception in finally block
Browse files Browse the repository at this point in the history
The fix introduced for #46 contained a bug. `ChargePoint.call()`
could fail with:

	try:
	    await self._send(call.to_json())
	    response = \
		await self._get_specific_response(call.unique_id,
						  self._response_timeout)
	finally:
	    self._call_lock.release()
>           raise
E           RuntimeError: No active exception to reraise
  • Loading branch information
Auke Willem Oosterhoff committed Nov 18, 2019
1 parent 223636a commit 90c2600
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions ocpp/charge_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,16 +247,11 @@ async def call(self, payload):

# Use a lock to prevent make sure that only 1 message can be send at a
# a time.
await self._call_lock.acquire()

try:
async with self._call_lock:
await self._send(call.to_json())
response = \
await self._get_specific_response(call.unique_id,
self._response_timeout)
finally:
self._call_lock.release()
raise

if response.message_type_id == MessageType.CallError:
LOGGER.warning("Received a CALLError: %s'", response)
Expand Down

0 comments on commit 90c2600

Please sign in to comment.