Socket Thread and PyGTK

后端 未结 1 1952
醉梦人生
醉梦人生 2021-01-21 01:48

I\'m trying to write a instant messaging program, the basic ui is almost finished and i\'m looking into the receiving part of messages. I have an UI class and a threaded Receive

相关标签:
1条回答
  • 2021-01-21 01:54
    1. No. Don't use threads. Instead, use glib.io_add_watch to make gtk/glib itself call your function when the socket is ready to read. That way you won't freeze your gui and won't need threads. You also won't need idle_add.

    2. If you do 1, you won't have this problem, since messages will arrive in order and there will be no concurrent threads to confuse the data.

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