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


Groups > comp.lang.python > #91995

Re: Multiple thread program problem

Path csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python@mrabarnett.plus.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'f.close()': 0.07; 'skip:/ 10': 0.07; 'arg': 0.09; 'identifier,': 0.09; 'int.': 0.09; 'thu': 0.09; 'typeerror:': 0.09; 'x86_64': 0.09; 'thread': 0.10; 'def': 0.14; 'argument': 0.15; 'result.': 0.15; '2014': 0.16; 'edt': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'received:192.168.1.4': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'subject:program': 0.16; 'subprocess': 0.16; 't.start()': 0.16; 'threading': 0.16; 'uname': 0.16; 'wrote:': 0.16; 'skip:" 30': 0.20; 'trying': 0.22; 'subject:problem': 0.22; 'passing': 0.23; 'import': 0.24; 'header :In-Reply-To:1': 0.24; '(most': 0.24; 'header:User-Agent:1': 0.26; 'linux': 0.26; 'error': 0.27; 'callable': 0.29; 'starts': 0.29; 'print': 0.31; 'skip:s 30': 0.31; 'received:84': 0.32; 'getting': 0.33; 'traceback': 0.33; 'running': 0.34; 'file': 0.34; 'to:addr :python-list': 0.35; 'execution': 0.35; 'skip:o 20': 0.35; 'but': 0.36; 'should': 0.37; 'subject:: ': 0.37; 'skip:- 20': 0.37; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'smp': 0.84
X-CM-Score 0.00
X-CNFS-Analysis v=2.1 cv=OoyysHLt c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=QrohdLjRRo4A:10 a=IkcTkHD0fZMA:10 a=EBOSESyhAAAA:8 a=PDHGuUMrAAAA:8 a=tWrObIyxaiSE4VgD7vcA:9 a=QEXdDO2ut3YA:10
X-AUTH mrabarnett@:2500
Date Wed, 03 Jun 2015 21:59:47 +0100
From MRAB <python@mrabarnett.plus.com>
User-Agent Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0
MIME-Version 1.0
To python-list@python.org
Subject Re: Multiple thread program problem
References <5eba09c9-aadb-46d9-b644-8ba775d8b97a@googlegroups.com>
In-Reply-To <5eba09c9-aadb-46d9-b644-8ba775d8b97a@googlegroups.com>
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
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.128.1433365371.13271.python-list@python.org> (permalink)
Lines 42
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1433365371 news.xs4all.nl 2908 [2001:888:2000:d::a6]:35152
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:91995

Show key headers only | View raw


On 2015-06-03 21:41, Mohan Mohta wrote:
> Hello
> I am trying to create multiple thread through the below program but I am getting an error
>
> #! /usr/bin/python
> import os
> import subprocess
> import thread
> import threading
> from thread import start_new_thread
>
> def proc(f) :
>          com1="ssh -B "
>          com2=line.strip('\n')
>          com3= " uname -a"
>          co=str("ssh -B ")+ str(com2) + str(" uname -a")
>          subprocess.call(co,shell=True)
>          print "----------------------------"
>          return
>
> f = open('/tmp/python/1')
> for line in f:
>          t=thread.start_new_thread(proc(f),())
>          t.start()
> f.close()
> c = raw_input(" Type anything to quit")
>
>
> Execution output:
> Linux abc.myhomenetwork.com 2.6.18-348.25.1.el5 #1 SMP Thu Apr 10 06:32:45 EDT 2014 x86_64 x86_64 x86_64 GNU/Linux
> ----------------------------
> Traceback (most recent call last):
>    File "./readfile1.py", line 19, in <module>
>      t=thread.start_new_thread(proc(f),())
> TypeError: first arg must be callable
>
The first argument should be the function. You're calling proc(f) and 
the passing its result.

Also, start_new_thread starts the thread running immediately and
returns its identifier, an int.

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


Thread

Multiple thread program problem Mohan Mohta <mohan.mohta@gmail.com> - 2015-06-03 13:41 -0700
  Multiple thread program problem Sam Raker <sam.raker@gmail.com> - 2015-06-03 14:01 -0700
    Re: Multiple thread program problem Mohan Mohta <mohan.mohta@gmail.com> - 2015-06-03 15:23 -0700
      Re: Multiple thread program problem Mohan Mohta <mohan.mohta@gmail.com> - 2015-06-03 16:45 -0700
        Re: Multiple thread program problem sohcahtoa82@gmail.com - 2015-06-03 16:56 -0700
          Re: Multiple thread program problem M2 <mohan.mohta@gmail.com> - 2015-06-03 17:04 -0700
            Re: Multiple thread program problem Cameron Simpson <cs@zip.com.au> - 2015-06-04 10:37 +1000
              Re: Multiple thread program problem M2 <mohan.mohta@gmail.com> - 2015-06-03 19:59 -0700
                Re: Multiple thread program problem Cameron Simpson <cs@zip.com.au> - 2015-06-04 14:42 +1000
  Re: Multiple thread program problem MRAB <python@mrabarnett.plus.com> - 2015-06-03 21:59 +0100
  Re: Multiple thread program problem Gary Herron <gherron@digipen.edu> - 2015-06-03 15:02 -0700
  Re: Multiple thread program problem M2 <mohan.mohta@gmail.com> - 2015-06-04 10:20 -0700
    Re: Multiple thread program problem Cameron Simpson <cs@zip.com.au> - 2015-06-05 08:58 +1000

csiph-web