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


Groups > comp.lang.python > #26903

Re: Threads and sockets

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!news-out.readnews.com!transit3.readnews.com!panix!not-for-mail
From Grant Edwards <invalid@invalid.invalid>
Newsgroups comp.lang.python
Subject Re: Threads and sockets
Date Fri, 10 Aug 2012 22:38:23 +0000 (UTC)
Organization PANIX Public Access Internet and UNIX, NYC
Lines 21
Message-ID <k042gv$24c$1@reader1.panix.com> (permalink)
References <775f30ad-1f04-4653-95c4-b0dfdd27ca49@googlegroups.com>
NNTP-Posting-Host c-24-118-110-103.hsd1.mn.comcast.net
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
X-Trace reader1.panix.com 1344638303 2188 24.118.110.103 (10 Aug 2012 22:38:23 GMT)
X-Complaints-To abuse@panix.com
NNTP-Posting-Date Fri, 10 Aug 2012 22:38:23 +0000 (UTC)
User-Agent slrn/0.9.9p1 (Linux)
Xref csiph.com comp.lang.python:26903

Show key headers only | View raw


On 2012-08-10, loial <jldunn2000@gmail.com> wrote:

> At the moment I do not start to read responses until the data has
> been sent to the printer. However it seems I am missing some
> responses from the printer whilst sending the data, so I need to be
> able to do the 2 things at the same time.
>
> Can I open a port once and then use 2 different threads, one to write
> to the post and one to read the responses)?

By "port" I assume you mean a TCP connection using the 'socket' module?

If so, then yes you can write using one thread and read using a
second thread.  I do that all the time.

Sometimes it's simpler to use a single thread that uses select or
poll, and sometimes it's simpler to use multiple threads.  And you
never know which way is best until you're half way down the wrong
road...

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


Thread

Threads and sockets loial <jldunn2000@gmail.com> - 2012-08-10 06:01 -0700
  Re: Threads and sockets Dieter Maurer <dieter@handshake.de> - 2012-08-10 18:38 +0200
  Re: Threads and sockets Grant Edwards <invalid@invalid.invalid> - 2012-08-10 22:38 +0000
  Re: Threads and sockets Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-08-13 09:15 +0200

csiph-web