Skip to content

Commit

Permalink
conditional await
Browse files Browse the repository at this point in the history
  • Loading branch information
r0fls committed Nov 28, 2024
1 parent be975a4 commit 9040459
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion brokers/base_broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ async def is_order_filled(self, order_id):
'''Check if an order has been filled'''
logger.debug('Checking if order has been filled', extra={'order_id': order_id})
try:
return await self._is_order_filled(order_id)
if asyncio.iscoroutinefunction(self._is_order_filled):
return await self._is_order_filled(order_id)
else:
return self._is_order_filled(order_id)
except Exception as e:
logger.error('Failed to check if order has been filled', extra={'error': str(e)})
return False
Expand Down

0 comments on commit 9040459

Please sign in to comment.