Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.034 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'threads,': 0.09; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'port.': 0.22; 'seems': 0.23; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.28; 'post': 0.28; 'mini': 0.29; 'writes:': 0.29; 'framework': 0.30; 'could': 0.32; 'to:addr :python-list': 0.33; 'data,': 0.35; 'recieve': 0.35; 'open': 0.35; 'received:org': 0.36; 'should': 0.36; 'charset:us-ascii': 0.36; 'moment': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'things': 0.38; 'possible.': 0.38; 'to:addr:python.org': 0.39; 'application': 0.40; 'header:Received:5': 0.40; 'back': 0.62; 'different': 0.63; 'received:217': 0.68; 'printer': 0.84; 'responses': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dieter Maurer Subject: Re: Threads and sockets Date: Fri, 10 Aug 2012 18:38:37 +0200 References: <775f30ad-1f04-4653-95c4-b0dfdd27ca49@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Gmane-NNTP-Posting-Host: pd9e091f8.dip0.t-ipconnect.de User-Agent: Gnus/5.1008 (Gnus v5.10.8) XEmacs/21.4.22 (linux) Cancel-Lock: sha1:/1pHZL4YSwgj1TfcePETUlVP6O0= X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 11 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1344616733 news.xs4all.nl 6890 [2001:888:2000:d::a6]:38887 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:26879 loial writes: > I am writing an application to send data to a printer port(9100) and then recieve PJL responses back on that port. Because of the way PJL works I have to do both in the same process(script). > > 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)? That should be possible. Alternatively, you could use "asyncore" -- a mini framework to facilitate asynchronous communication.