python: how to send packets in multi thread and then the thread kill itself

后端 未结 7 1560
忘掉有多难
忘掉有多难 2020-12-03 12:40

I have a question. I\'d like to send a continuous streams of byte to some host for certain amount of time (let\'s say 1 minute) using python.

Here is my code so far

相关标签:
7条回答
  • 2020-12-03 13:33

    As mentioned above, use the threading module, it is much easier to use and provides several synchronization primitives. It also provides a Timer class that runs after a specified amount of time.

    If you just want the program to exit, you can simply make the sending thread a daemon. You do this by calling setDaemon(True) before calling start() (2.6 might use a daemon attribute instead). Python won't exit so long as a non-daemon thread is running.

    0 讨论(0)
提交回复
热议问题