Skip to content

Graceful cleanup for multiprocess pool python

I am running a multiprocessing pool, mapped over a number of inputs. My worker processes have an initialization step that spins up a connection to selenium and a database. When the pool finishes its job, what is the graceful way to close these connections rather than just relying on python’s memory mana…

Error comparing dask date month with an integer

The dask map_partitions function in the code below has a dask date field where its month is compared to an integer. This comparison fails with the following error: ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all(). What is this error and how to fix it? A…

exchanging data between node and Python with python-shell

I am trying to learn how to exchange data between Node and Python with python-shell, on the git repo they have some example code: Borrowing some of this code, this is app.js: And this is my_script.py below that will just print the weekday and current time: When run app.js this throws an error: Any ideas to tr…

discord.py: too big variable?

I’m very new to python and programming in general, and I’m looking to make a discord bot that has a lot of hand-written chat lines to randomly pick from and send back to the user. Making a really huge variable full of a list of sentences seems like a bad idea. Is there a way that I can store the