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


Groups > comp.lang.python > #63549

Re: Learning python networking

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'anyway.': 0.05; 'subsequent': 0.05; 'nicely': 0.07; 'socket': 0.07; 'callback': 0.09; 'dan': 0.09; 'hooks': 0.09; 'separating': 0.09; 'suppress': 0.09; 'things,': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'jan': 0.12; 'thread': 0.14; "wouldn't": 0.14; 'easier.': 0.16; 'fork': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'guess.': 0.16; 'personally,': 0.16; 'reason),': 0.16; 'spawn': 0.16; 'tends': 0.16; 'thread,': 0.16; 'subject:python': 0.16; 'do,': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'module': 0.19; 'mechanism': 0.19; 'thu,': 0.19; 'work,': 0.20; 'command': 0.22; 'separate': 0.22; 'cc:addr:python.org': 0.22; 'module,': 0.24; 'server.': 0.24; "haven't": 0.24; 'cc:2**0': 0.24; "i've": 0.25; 'solutions.': 0.26; 'header:In- Reply-To:1': 0.27; 'function': 0.29; 'leave': 0.29; 'am,': 0.29; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; '(which': 0.31; 'gives': 0.31; 'code': 0.31; 'that.': 0.31; '(on': 0.31; 'inspect': 0.31; 'though.': 0.31; "user's": 0.31; 'allows': 0.31; 'figure': 0.32; 'quite': 0.32; 'text': 0.33; 'running': 0.33; 'maybe': 0.34; "i'd": 0.34; 'etc': 0.35; 'operations': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; 'data,': 0.36; 'changing': 0.37; 'remote': 0.38; 'problems': 0.38; 'files': 0.38; 'fact': 0.38; 'rather': 0.38; 'does': 0.39; 'aside': 0.39; 'extremely': 0.39; 'structure': 0.39; 'system.': 0.39; 'even': 0.60; 'easy': 0.60; 'simple,': 0.60; 'most': 0.60; 'simply': 0.61; 'simple': 0.61; 'first': 0.61; 'line,': 0.68; 'fact,': 0.69; 'friendly': 0.72; 'incoming': 0.72; 'gotten': 0.74; '3.4': 0.84; 'asynchronous': 0.84; 'complex,': 0.84; "everything's": 0.84; 'much,': 0.84; 'pike': 0.84; 'plays': 0.84; 'popup': 0.84; 'carries': 0.91; 'to:none': 0.92
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=TbdIlq7AvNbr9IiojGlp3k2zdNx5sOLB2f1z9enROmI=; b=xsTpYbje659/i0qgI0qIsb9D21N1KlBG3ZwXKjEAex9XgjmMN+q1bMbZcGDfj3UZPr aYHQdFDO3m5l4vJ/tm+rcKCToyv6poN7IueNkDTqnOodVTdpN2bhGsj0f7jvjy/0/GDp Z40zWK+GDjewleSOUNp/Ji6FFiHqNx821jR2EdEq1ETGeJSZ+m2uzqus92KJKEP9w7UQ YuLGk32RlTKe4BR4M1AUKeZbhhHVNrSCtqSALn6vYOz/GveMqXNPUtmJ9pDSefhFp35J HaYBEpA8fidwXT+mbnGLQsuDvaCDcoTFUKRYCzHH6DMmua6Cykf45NuiZtD7wQjuUkeJ qNtw==
MIME-Version 1.0
X-Received by 10.66.118.71 with SMTP id kk7mr124741pab.14.1389226025288; Wed, 08 Jan 2014 16:07:05 -0800 (PST)
In-Reply-To <CAGGBd_rVOwBT_h0-X72Mhve3DEBg1Qvo6s-PS-=8aKkRXonUKg@mail.gmail.com>
References <22d58d76-f2c2-4a1d-8049-3409ac4665d3@googlegroups.com> <CAPTjJmr-4HbCjqfDjTrjLzvoE4BYr6_OS=BBqRLFg4_BtV4iSw@mail.gmail.com> <CAGGBd_rVOwBT_h0-X72Mhve3DEBg1Qvo6s-PS-=8aKkRXonUKg@mail.gmail.com>
Date Thu, 9 Jan 2014 11:07:05 +1100
Subject Re: Learning python networking
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.5220.1389227742.18130.python-list@python.org> (permalink)
Lines 41
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1389227742 news.xs4all.nl 2910 [2001:888:2000:d::a6]:33907
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:63549

Show key headers only | View raw


On Thu, Jan 9, 2014 at 10:53 AM, Dan Stromberg <drsalists@gmail.com> wrote:
>> Using Python 3.4 (which isn't yet
>> stable, but you can download betas) also gives you an asyncio module,
>> but I'd leave that aside for the moment; first figure out threading,
>> it's likely to be easier.
>
> Personally, I don't like asynchronous I/O, EG twisted.  It tends to
> give very complex, uniprocessor solutions to problems, even when those
> problems have quite simple, alternative solutions.  I'd rather just
> accept and fork in most cases, with or without multiprocessing.

I haven't used the Python asyncio module yet (haven't gotten around to
it, no other reason), but in my Pike work, I've gotten quite friendly
with a callback system. It plays nicely with the structure I have for
code reloading, by separating code and data, and then simply running
everything off a single thread, one callback at a time. Works really
well when everything's waiting anyway. It does force you to think
about things differently, though. Case in point: My MUD client allows
an arbitrary number of code files to inspect a line of text that the
user's entered, before it goes to the server. Any one of them can
suppress the line, in which case subsequent hooks won't see it and it
won't go to the server. What about changing the line as it goes
through? That's easy enough, I guess. But what if that change involves
a popup message and user response... or a network request to a remote
server? (I do, in fact, have exactly that. Long URLs get shortened via
tinyurl.com.) A threaded model wouldn't even help much, here, unless
I'm prepared to spawn a separate thread for every command the user
enters, which is stupid overhead. Instead, I have a function that
reinjects the line and carries on as if it hadn't been suppressed in
the first place.

Maybe it's not the best way to do things, but it can be extremely
simple in the code. Most operations don't even need the
continuation-call mechanism that I used there; mostly, everything's
just (conceptually) "when this happens, call this function". The fact
that they're serialized doesn't matter. Events from the GUI, incoming
socket data (on any socket - there might be multiple), time-delay
events (eg a ticking clock), etc - everything works the same way. It's
really easy once you get your head around it.

ChrisA

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


Thread

Learning python networking Paul Pittlerson <menkomigen6@gmail.com> - 2014-01-08 14:27 -0800
  Re: Learning python networking Chris Angelico <rosuav@gmail.com> - 2014-01-09 10:29 +1100
    Re: Learning python networking Paul Pittlerson <menkomigen6@gmail.com> - 2014-01-15 02:37 -0800
      Re: Learning python networking Denis McMahon <denismfmcmahon@gmail.com> - 2014-01-15 11:11 +0000
      Re: Learning python networking Chris Angelico <rosuav@gmail.com> - 2014-01-15 23:52 +1100
      Re: Learning python networking "Frank Millman" <frank@chagford.com> - 2014-01-15 15:31 +0200
      Re: Learning python networking Chris Angelico <rosuav@gmail.com> - 2014-01-16 01:07 +1100
      Re: Learning python networking Chris Angelico <rosuav@gmail.com> - 2014-01-16 02:36 +1100
      Re: Learning python networking Chris Angelico <rosuav@gmail.com> - 2014-01-16 03:31 +1100
      Re: Learning python networking Chris Angelico <rosuav@gmail.com> - 2014-01-16 03:32 +1100
      Re: Learning python networking William Ray Wing <wrw@mac.com> - 2014-01-15 11:43 -0500
      Re: Learning python networking Chris Angelico <rosuav@gmail.com> - 2014-01-16 04:07 +1100
      Re: Learning python networking William Ray Wing <wrw@mac.com> - 2014-01-15 11:25 -0500
  Re: Learning python networking Dan Stromberg <drsalists@gmail.com> - 2014-01-08 15:53 -0800
  Re: Learning python networking Chris Angelico <rosuav@gmail.com> - 2014-01-09 11:07 +1100
  Re: Learning python networking Dan Stromberg <drsalists@gmail.com> - 2014-01-08 19:49 -0800
    Re: Learning python networking Alister <alister.ware@ntlworld.com> - 2014-01-09 11:32 +0000
  Re: Learning python networking Chris Angelico <rosuav@gmail.com> - 2014-01-09 15:20 +1100

csiph-web