Correct way to stop a market data collection and remove database

Supposing I have an active market data collection that I want to cancel and then start a new one as soon as possible, What is the better way to cancel the collection, including delete the related database?

For the moment we use the following code:

drop_db(universe_database_name, confirm_by_typing_db_code_again=universe_database_name, cascade=True)

Although it works, it sometimes raises the following error:

ERROR psycopg2.InterfaceError: connection already closed

I’m not sure why it’s happening but cancelling data collection doesn’t usually involve dropping the database since databases are usually kept for awhile, so maybe it has to do with that quick succession. Perhaps try delaying somewhat before dropping the database?

1 Like