Category : python

I’m trying to understand the Keep Alive (py::keep_alive) feature of pybind11. Specifically under what circumstances it needs to be used. The documentation provides this example: Consider the following example: here, the binding code for a list append operation ties the lifetime of the newly added element to the underlying container: py::class_<List>(m, "List") .def("append", &List::append, py::keep_alive<1, ..

Read more

I have this code running in a separate thread: main.py: if __name__ == ‘__main__’: try: threading.Thread(target=pull_data_from_file, args=()).start() except Exception as e: print(e) other file: import asyncio import asyncio def pull_data_from_file(): asyncio.run(handle_pd_data_messages()) async def handle_data_messages(): uri = properties[‘websocket_uri’] while True: try: async with websockets.connect(uri) as websocket: async for message in websocket: try: json_data = json.loads(message) json_data[‘msg’] ..

Read more

I want to keep nightlight on the whole time, but Windows keeps turning if off randomly/once the pc is locked. I tried adding a new .reg which unfortunately didn’t really help. I wanted to make a batch/python script that enables nightlight every 5 minutes, but I have no idea what the code would look like. ..

Read more

Please consider the following C++ pybind11 program: #include <pybind11/embed.h> namespace py = pybind11; int main() { py::scoped_interpreter guard{}; py::dict locals; py::exec(R"( import sys def f(): print(sys.version) )", py::globals(), locals); locals["f"](); // <– ERROR } The py::exec call and the enclosed import sys call both succeed, but the call locals["f"]() throws an exception: NameError: name ‘sys’ ..

Read more

I currently started a new job where my first project will be to create a GUI application. Currently the application will require reading/writing functionality from either a database or flatfile system. Also future requirements may include connection to VPN and automatic emailing. I am most experienced at coding in python, however I am curious as ..

Read more

This is what occurs when installing the pyinstaller, please help me solve this. pip install pyinstaller WARNING: Ignoring invalid distribution -p (c:python310libsite-packages) WARNING: Ignoring invalid distribution -p (c:python310libsite-packages) WARNING: Ignoring invalid distribution -ip (c:python310libsite-packages) WARNING: Ignoring invalid distribution – (c:python310libsite-packages) WARNING: Ignoring invalid distribution -p (c:python310libsite-packages) WARNING: Ignoring invalid distribution -p (c:python310libsite-packages) WARNING: Ignoring invalid ..

Read more