PyLabRobot is now asynchronous, based on Python’s asyncio. This will make the implementation of complex methods significantly easier.
Each operation can be awaited using await
:
await lh.aspirate(...)
or
fut = lh.aspirate(...)
# do something else in between
await fut
In IPython/Jupyter Notebooks, you can use await
directly.
In scripts, I recommend using asyncio.run()
:
import asyncio
async def my_method():
await lh.aspirate(...)
asyncio.run(my_method())
One of the many neat features of asyncio is gather
, which can be used to run two actions simultaneously:
async def pipetting_sequence():
await lh.aspirate(...)
await lh.dispense(...)
asyncio.gather([
pr.read_absorbance(...),
pipetting_sequence()
])
Depending on the model of robot, running two ‘active operations’ (such as aspirate/dispense) simultaneously might raise an error. This is the case on STAR. You can, however, aspirate while performing ‘passive operations’.