David Flores
03/14/2024, 8:30 AMmy_client = AwesomeService(**params)
# Initialisation
my_client.open()
# Do the task
my_client.do_the_task(abc)
# Close the session
my_client.close()
I would like to refactor the code in a way that my_client.do_the_task
is actually a @task
in prefect, but I don't know if is a best practice to have all this code in just one task, because if I want to use it in a concurrent manner with submit
it would open and close multiple sessions - and ideally it would be just one "open" - do all the things you want to do - and one "close". And for this I might need to send the client as parameter to the task... right?
Don't know if someone has stumbled into this kind of refactor issue/dilemma here 😅Tim Galvin
03/14/2024, 8:44 AMDavid Flores
03/14/2024, 8:48 AMSession
object or a DockerClient
or even a network device client like netmiko/paramiko
David Flores
03/14/2024, 8:50 AMDavid Flores
03/14/2024, 8:50 AMElasticsearch()
from their python library - https://elasticsearch-py.readthedocs.io/en/v8.2.2/index.html#example-usage