Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6857757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:04:05+00:00 2026-05-27T02:04:05+00:00

I wanted to run a certain function as a thread, but I get SyntaxError:

  • 0

I wanted to run a certain function as a thread, but I get

SyntaxError: non-keyword arg after keyword arg

And I do not understand why :

#!/usr/bin/env python
import sys
import arduinoReadThread
import arduinoWriteThread
import socket
import thread

bolt = 0
socketArray=list()
HOST ="localhost"
PORT1 =50000
PORT2 =50001

def readAndParseArgv():
    s=socket.socket(socket.AF_INET, socket.SOCK_STREAM ) #create an INET, STREAMing socket
    s.bind((HOST,PORT1)) #bind to that port
    print "test"
    s.listen(2) #listen for user input and accept 1 connection at a time.
    socketArray.append(s)
    s2=socket.socket(socket.AF_INET, socket.SOCK_STREAM ) #create an INET, STREAMing socket
    s2.bind((HOST,PORT2)) #bind to that port
    print "test"
    s2.listen(2) #listen for user input and accept 1 connection at a time.
    socketArray.append(s2)

def socketFunctionWrite1():
    print threadName
    client, address = s1.accept()
    while(bolt == 0):
        print "Writing connections"
        if len(s1ToWriteList) > 0:
            client.send(s1ToWriteList.pop(0))

def socketFunctionRead1():
    client, address = s2.accept()
    while(bolt == 0):
        f = client.recv(1024)
        print "reading connection"
        s1ToWriteList.append(f)
        print len(s1ToWriteList)

def socketFunctionWrite2():
    client, address = s2.accept()
    while(bolt == 0):
        print "Writing connections"
        if len(s2ToWriteList) > 0:
            client.send(s2ToWriteList.pop(0))

def socketFunctionRead2():
    client, address = s1.accept()
    while(bolt == 0):
        f = client.recv(1024)
        print "reading connection"
        s2ToWriteList.append(f)
        print len(s2ToWriteList)

def shutDown():
    test = raw_input("Quit ?")
    if(test =="y"):
        bolt = 1
    else:
        shutDown()

thread.start_new_thread(target=socketFunctionRead1,())
thread.start_new_thread(target=socketFunctionWrite1,())
thread.start_new_thread(target=socketFunctionRead2,())
thread.start_new_thread(target=socketFunctionWrite2,())

readAndParseArgv()
spreadSockets()

I want to open these sockets as threads. I do not get why I get the non-keyword error, as the function I want to run as a thread is socketFunctionRead1

error :

  File "pythonbis.py", line 79
    thread.start_new_thread(target=socketFunctionRead1,())
SyntaxError: non-keyword arg after keyword arg
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T02:04:06+00:00Added an answer on May 27, 2026 at 2:04 am

    The docs say the the signature for the thread.start_new_thread call is:

    thread.start_new_thread(function, args[, kwargs])
    

    The way you are calling it is:

    thread.start_new_thread(target=socketFunctionRead1,())
    

    As you can see you are passing a named (keyword) argument before the non-named one: you are saying target=socket... before ().

    EDIT: just to clarify. The solution is either to remove the keyword to the first argument or to add it to the second.

    HTH!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I wanted to run a query where certain fields in my query were
I wanted use MVC and renderpartial to generate a menu but but could not
I wanted to run 1,000 iterations of a program, so set a counter for
In a macro for Visual Studio 6, I wanted to run an external program,
I've run into a little hurdle and wanted to see if somebody could help
I just wanted some opinions from people that have run Selenium ( http://selenium.openqa.org )
When you run top and see all running processes, I've always wanted to know
I have a program that I run through the command line and I wanted
Wanted to get some consensus around a UI feature I'm working on right now.
I am trying to run a certain macro in very short intervals, such as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.