Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.033 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; 'python,': 0.02; 'subject:design': 0.09; 'suggestions.': 0.09; 'tcp/ip': 0.09; 'subject:How': 0.10; 'python': 0.11; 'thread': 0.14; 'confuse': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'latter,': 0.16; 'multi-thread': 0.16; 'multithread': 0.16; 'processes.': 0.16; 'thinking,': 0.16; 'threads,': 0.16; 'language': 0.16; 'wrote:': 0.18; 'all,': 0.19; 'module': 0.19; 'trying': 0.19; 'version.': 0.19; 'not,': 0.20; 'otherwise,': 0.22; 'separate': 0.22; 'case.': 0.24; 'server.': 0.24; 'options': 0.25; 'header:In-Reply-To:1': 0.27; 'idea': 0.28; 'message- id:@mail.gmail.com': 0.30; 'easier': 0.31; 'you?': 0.31; '25,': 0.31; 'easy,': 0.31; 'ray': 0.31; 'probably': 0.32; 'figure': 0.32; 'run': 0.32; 'quite': 0.32; 'open': 0.33; 'fri,': 0.33; 'could': 0.34; 'knowledge': 0.35; 'connection': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; 'doing': 0.36; 'possible': 0.36; 'server': 0.38; 'thank': 0.38; 'connections': 0.38; 'others.': 0.38; 'process,': 0.38; 'to:addr :python-list': 0.38; 'pm,': 0.38; 'rather': 0.38; 'though,': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'matter': 0.61; 'simply': 0.61; "you're": 0.61; 'you.': 0.62; 'within': 0.65; 'between': 0.67; 'sound': 0.68; 'connection.': 0.74; 'obvious': 0.74; 'subject:One': 0.74; 'asynchronous': 0.84; 'divide': 0.84; 'started,': 0.84; 'subject:Client': 0.84; 'subject::': 0.85; 'subject:Server': 0.91; 'transactions': 0.91; 'yourself,': 0.95; '2013': 0.98 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:to :content-type; bh=QrEEXaJBpk0MIe0wQOqtpZIlyv+FgfX4VgnsJOmUKqo=; b=tpUHaU3dIp8ylSYaK6FA+C4oXwv5GtdJUILPjVD++fImScX2oWnxSLX6XX0faFbiAZ j5bhz3H41VJWU4Np3dbmpMCcmimNNMOob1j8CRqf5mRQs8uxgiD125qU2V+pB5TrTnVu 2trSY5RXVEoL+9gzTdnsKgx5MNVvUZIbYi08ili1RJhD9+qS62Wfef7H0A8SNlCwQGjg MNzcmmdtqUd3F8wwkQw66H4sP7Dabb4a/Gri+/23ZZTQ7rozUFU8UB9WPtySmca8QdxX cXSPalbNZCHc2RPueG3+JyrvGjAZF9CxUOOsbwzpXXCFBRCVdiBvgcNNgl1ZNP9iqSM3 Xh3w== MIME-Version: 1.0 X-Received: by 10.68.182.3 with SMTP id ea3mr897453pbc.124.1382696716405; Fri, 25 Oct 2013 03:25:16 -0700 (PDT) In-Reply-To: <0626cc7c-d4fd-4d6e-ac3d-9a85a725b5fb@googlegroups.com> References: <0626cc7c-d4fd-4d6e-ac3d-9a85a725b5fb@googlegroups.com> Date: Fri, 25 Oct 2013 21:25:16 +1100 Subject: Re: How to design:Use One TCPIP Client connection to Server and work concurrently From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 43 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1382696725 news.xs4all.nl 15928 [2001:888:2000:d::a6]:60374 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:57511 On Fri, Oct 25, 2013 at 9:06 PM, ray wrote: > Hi all, > The system use ONE tcpip client and connection to server. > A large batch transactions send to server.I want to send to server concurrently. > any idea ? > In my thinking, > A.Devide large batch transactions to small batch transactions. > B.Create multi-thread or multiprocessing to process small transactions. > C.No idea at how to control multithread using ONE client concurrently? > Each small transactions do not need to wait others > Thank for your suggestions. Are you able to open multiple TCP/IP connections to the server and run them in parallel? If not, you're going to be limited to what the server can do for you. Otherwise, though, it's just a matter of working out how best to manage multiple connections. * You can manage everything with a single thread and asynchronous I/O. This would probably be easier if you're on Python 3.4, but it's possible with any version. * Or you can spin off threads, one for each connection. This can work nicely, but if you don't know how to get your head around threads, you may confuse yourself, as has been recently discussed in other threads (discussion threads, that is, not threads of execution - what a crackjaw language this English is!). * Or you can use the multiprocessing module and divide the work into several processes. Again, you have to figure out what you're doing where, but this can in some ways be a lot easier than threading because each process, once started, is completely separate from the others. * Or, rather than manage it within Python, you could simply start multiple independent processes. Somehow you need to figure out how to divide the transactions between them. Could be really easy, but could be quite tricky. I suspect the latter, in this case. There are many ways to do things; figuring out which is the One Obvious Way demands knowledge of what you're trying to achieve. Do any of the above options sound good to you? ChrisA