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 8944807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:06:20+00:00 2026-06-15T12:06:20+00:00

Yes other people have asked this question before, but not in the same context

  • 0

Yes other people have asked this question before, but not in the same context or to my satisfaction. So, here goes::

I am writing an application using python, the program using pygame (ergo opengl) to display the graphics. The graphics are generated in the program itself (so no directory issues whatsoever).

The application also needs to access the input parallely from a user. To achieve this I use a multiprocessing block with a pipe and read the input key using pygame event loop. The below code runs in a loop. The first loop iteration works fine, but on the 2nd iteration I am thrown that XIO error.

   parent, child = Pipe(duplex=True)
   # this function draws the canvas
   switches, retOrient = self.drawCanvas(cond, count, dispSize, moves)
   # this function gets the user input in another thread - stage 1
   p = Process(target=userInput, args=(self.button, child) )
   p.start()
   b_press = parent.recv()
   parent.close()

def userInput(button, child):
    button_pressed = button.blockAndWait()
    child.send( "%s"%(button_pressed.keyname) )
    child.close()

I am a little perplexed at how this error occurs, what are the internals in XIO that cause it. None of the other answers actually explain the root cause of this error. Considering it works fine as a single process application, the multiprocessing module is closing some IO channel (the input registered object, the display object or the event loop) or opening some unnecessary channels. How can I decipher what exactly is causing this XIO error?

  • 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-06-15T12:06:22+00:00Added an answer on June 15, 2026 at 12:06 pm

    Not necessarily a real answer, but I would not use multiprocessing to parallelize access to sockets like the connection to the X server. That looks like a bad idea. Use regular threads instead.

    Be aware that multiprocessing is a hack based (sometimes) on forking, so what exactly occurs with a forked socket when both the parent and the child try to access it… is random mixed garbage.

    EDIT: the reason is that both forked sockets are still the “same end” of the socket, with the X server holding on the “other end”. When the X server wants to send a message, it writes, say, 100 bytes on the socket. But if you’re unlucky, the forked process 1 reads the first 50 bytes and the forked process 2 reads the remaining 50 bytes. Each process is unexpectedly getting only a random part of the message. They will each complain that the X server is sending nonsense.

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

Sidebar

Related Questions

Yes, I know this question has been asked before, but I can't find an
This has been asked before by other people, but I've never seen an adequate
Yes, I know this question has been asked a lot of times, but I
Yes, I have searched and tried many techniques, but nothing seems to work. Here
This is a very specific question that relates to a broader question asked here:
Yes, this is a really lazy question but I figure this is problem that
I know this question was asked by many people and there are several discussions
This is not a question as such, but more like a list of things
Yes, the only question is whether I'm doing it correct or not. And maybe
My Requirement: I have this straight forward requirement of listing names of people in

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.