asyncore

QObject (QPlainTextEdit) & Multithreading issues

帅比萌擦擦* 提交于 2019-11-29 02:20:59
Im currently trying to learn Networking with Python asyncore and pyqt4. I coded a small server, which basically listens on some port, and resends all messages it recieves to the sender. Since both qts QApplication.exec_() and asyncore.loop() are functions which never return i could not start them both in one thread, so i stared asyncore.loop() in a seperate daemon thread. Whenever my server class (derived from asyncore.dispatcher ) establishes or drops a connection, or sends/recieves a message, it calls methods of my window class (derived from QtGui.QMainWindow ), which displays the

How to handle asyncore within a class in python, without blocking anything?

a 夏天 提交于 2019-11-28 02:49:58
问题 I need to create a class that can receive and store SMTP messages, i.e. E-Mails. To do so, I am using asyncore according to an example posted here. However, asyncore.loop() is blocking so I cannot do anything else in the code. So I thought of using threads. Here is an example-code that shows what I have in mind: class MyServer(smtpd.SMTPServer): # derive from the python server class def process_message(..): # overwrite a smtpd.SMTPServer method to be able to handle the received messages ...

Asynchronous HTTP calls in Python

拜拜、爱过 提交于 2019-11-27 21:28:11
I have a need for a callback kind of functionality in Python where I am sending a request to a webservice multiple times, with a change in the parameter each time. I want these requests to happen concurrently instead of sequentially, so I want the function to be called asynchronously. It looks like asyncore is what I might want to use, but the examples I've seen of how it works all look like overkill, so I'm wondering if there's another path I should be going down. Any suggestions on modules/process? Ideally I'd like to use these in a procedural fashion instead of creating classes but I may

Which Python async library would be best suited for my code? Asyncore? Twisted?

此生再无相见时 提交于 2019-11-27 18:02:30
I have a program I'm working on that will be reading from two 'network sources' simultaneously. I wanted to try out an asynchronous approach rather than use threading. This has lead me to wonder which library to use... I've come up with some simple example code that kind of demonstrates what my program will be doing: import sniffer def first(): for station in sniffer.sniff_wifi(): log(station.mac()) def second(): for station in sniffer.sniff_ethernet(): log(station.mac()) first() second() The two sniffer methods look somewhat like this: def sniff_wifi(self): while True: yield mac_address The

QObject (QPlainTextEdit) & Multithreading issues

≯℡__Kan透↙ 提交于 2019-11-27 16:35:05
问题 Im currently trying to learn Networking with Python asyncore and pyqt4. I coded a small server, which basically listens on some port, and resends all messages it recieves to the sender. Since both qts QApplication.exec_() and asyncore.loop() are functions which never return i could not start them both in one thread, so i stared asyncore.loop() in a seperate daemon thread. Whenever my server class (derived from asyncore.dispatcher ) establishes or drops a connection, or sends/recieves a

Asynchronous HTTP calls in Python

*爱你&永不变心* 提交于 2019-11-27 04:31:58
问题 I have a need for a callback kind of functionality in Python where I am sending a request to a webservice multiple times, with a change in the parameter each time. I want these requests to happen concurrently instead of sequentially, so I want the function to be called asynchronously. It looks like asyncore is what I might want to use, but the examples I've seen of how it works all look like overkill, so I'm wondering if there's another path I should be going down. Any suggestions on modules

Which Python async library would be best suited for my code? Asyncore? Twisted?

微笑、不失礼 提交于 2019-11-26 19:19:50
问题 I have a program I'm working on that will be reading from two 'network sources' simultaneously. I wanted to try out an asynchronous approach rather than use threading. This has lead me to wonder which library to use... I've come up with some simple example code that kind of demonstrates what my program will be doing: import sniffer def first(): for station in sniffer.sniff_wifi(): log(station.mac()) def second(): for station in sniffer.sniff_ethernet(): log(station.mac()) first() second() The