I am using the python websocket-client package (https://pypi.org/project/websocket-client/) to subscribe to multiple websocket channels. I implemented the basic ping-pong logic using the websocket client package as below. The ping-pong logic is working mostly fine under normal circumstances and I am able to run the code for hours without many disconnect/reconnect instances. However, when I try to increase the number of
Tag: python-multithreading
Keep indefinite connections open on TCP server with asyncio streams?
I’m trying to understand how to use asyncio streams for multiple connections that will keep sending messages until a predefined condition or a socket timeout. Looking at Python docs, they provide the following example for a TCP server based on asyncio streams: What I’m trying to do is more complex and it looks more like so (a lot of it
How can I prevent other threads from running when a certain condition is met?
I created a situation in which two threads run continuously. My intention is to prevent all other threads from running when the “Printing Alphabet” portion of the “printAlphabet” function is entered, and when this prioritized thread is done running, all threads resume execution until the condition is met again. The “anotherThread” function continues to run even when this section is
Can’t stop thread at all (unless I cause an exception)
So I am working on a GUI (PyQt5) and I am multi-threading to be able to do data acquisition and real-time plotting concurrently. Long story short, all works fine apart from stopping the thread that handles the data acquisition, which loops continuously and calls PySerial to read the com port. When a button on the GUI is pressed, I want
Multithreading on object methods in python
I am trying to implement multi threading with oops But the test1.printHi is expecting me to pass self After passing self it is not being multi threaded any more It Its first printing all hi and then hello at last next is getting printed but when I implement them like functions its working properly they are getting printed at once
improve the throughput of sending multiple file via socket
At First, I don’t have any errors or bugs, I ask this question to understand more. I want to send multiple files concurrently via a separate connection to a server from a client. I used threads to make the sending process concurrent on the client-side. It sounds that it does improve the throughput a little bit. But I’m still confused.
time.sleep does not work for multithreaded
I was trying to multithread the code for “Suspend / Hibernate pc with python” provided by Ronan Paixão when I find that time.sleep() does not suspend the thread that run pywin32 module. >>> Warning! The following code will put Windows to sleep <<< The print function did waited for time.sleep(), but the Windows was immediately put to sleep. What happened?
Is it the right way to run 2 infiniteloop in python?
i wrote a code in python with 2 infinite loop like this: If i don’t join any thread it’s not working, but when i join 1 thread, another thread is work too but i don’t know why? Can anyone explain for me? Answer Join is used to block the calling method until the thread finishes, throws an exception or time
pass function from class without starting it python
I need to run two functions with the threading module you’re able to do this Thread(target=my_func) but i want the function from a class (imported class) so i tried Thread(target=a_class.my_func) but it didn’t worked, then i tried Thread(target=a_class.my_func()) but this one starts to run the function because i called it , and this is an infinite loop so the next
Upload large file using multiple connections/threads to an SFTP server with Python Paramiko
I am trying to SFTP a file to a remote server in chunks using threads and the python paramiko library. It opens a local file and sftp chunks to the remote server in different threads. I am basically following this solution which uses the same approach to download large file over SFTP. I would like to send large files instead.