Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #43359

Re: Problems with sockets and threads

Date 2013-04-11 07:27 -0500
From Wayne Werner <wayne@waynewerner.com>
Subject Re: Problems with sockets and threads
References <347b9197-b409-4651-8c01-26af4c3461ca@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.466.1365683257.3114.python-list@python.org> (permalink)

Show all headers | View raw


On Thu, 11 Apr 2013, Dexter Deejay wrote:

> When i try to run this code and to connect to server (server is written in java that part of code is ok) everything stalls. Thread that i created here occupies processor all the time and GUI freezes. It's supposed to be waiting for message from server. (asynchronous one) Is there something that i did wrong here, or is there better way to do this?
>
>
> from tkinter import *
> from threading import *

Everything I've read or used suggests to me that threading+tkinter is a 
dangerous combination.

Mainly because tkinter already has an event loop, so when you start mixing 
threads things tend to go sideways.

Instead what you'll want to do is put processing in the .after or 
.after_idle callbacks - just make sure that whatever is doing is quick (or 
can do a portion of the activity quickly).

HTH,
-W

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Problems with sockets and threads Dexter Deejay <djdexter1389@gmail.com> - 2013-04-11 05:14 -0700
  Re: Problems with sockets and threads Wayne Werner <wayne@waynewerner.com> - 2013-04-11 07:27 -0500
  Re: Problems with sockets and threads Dexter Deejay <djdexter1389@gmail.com> - 2013-04-11 05:34 -0700
    Re: Problems with sockets and threads Wayne Werner <wayne@waynewerner.com> - 2013-04-11 08:03 -0500
  Re: Problems with sockets and threads Dexter Deejay <djdexter1389@gmail.com> - 2013-04-11 06:10 -0700
  Re: Problems with sockets and threads Dexter Deejay <djdexter1389@gmail.com> - 2013-04-11 06:11 -0700
    Re: Problems with sockets and threads Dexter Deejay <djdexter1389@gmail.com> - 2013-04-11 07:21 -0700
  Re: Problems with sockets and threads Peter Otten <__peter__@web.de> - 2013-04-11 16:41 +0200
    Re: Problems with sockets and threads Dexter Deejay <djdexter1389@gmail.com> - 2013-04-11 08:39 -0700
    Re: Problems with sockets and threads Dexter Deejay <djdexter1389@gmail.com> - 2013-04-11 08:39 -0700

csiph-web