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


Groups > comp.lang.python > #25171

introduction and first question about multithreading

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <krecoun@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'python.': 0.02; 'python,': 0.02; 'subject:question': 0.08; 'python': 0.09; 'here?': 0.09; 'output,': 0.09; 'python:': 0.09; 'skip:` 30': 0.09; 'subject:skip:m 10': 0.09; 'thread': 0.11; 'finishes': 0.16; 'numpy': 0.16; 'pipes': 0.16; 'processes.': 0.16; 'pygame': 0.16; 'pygame.': 0.16; 'threading': 0.16; 'byte': 0.17; 'switched': 0.17; 'variables': 0.17; 'input': 0.18; 'windows': 0.19; 'module': 0.19; 'code.': 0.20; 'mostly': 0.20; 'import': 0.21; 'keyboard': 0.22; 'help.': 0.22; 'received:74.125.82.174': 0.23; 'programming': 0.23; 'player': 0.23; 'this:': 0.23; "haven't": 0.23; 'linux': 0.24; 'pass': 0.25; 'tried': 0.25; 'least': 0.25; 'header:User-Agent:1': 0.26; 'checking': 0.27; 'handling': 0.27; 'separate': 0.27; 'core': 0.27; 'interface': 0.27; 'run': 0.28; 'directly,': 0.29; 'queue': 0.29; 'unified': 0.29; 'that.': 0.30; 'function': 0.30; 'error': 0.30; 'primary': 0.30; 'launch': 0.32; 'running': 0.32; 'received:74.125.82': 0.33; 'platforms.': 0.33; 'ubuntu': 0.33; 'to:addr:python-list': 0.33; 'likely': 0.33; 'version': 0.34; 'received:google.com': 0.34; 'thanks': 0.34; 'needed': 0.35; 'sequence': 0.35; 'skip:. 20': 0.35; 'doing': 0.35; 'similar': 0.35; 'something': 0.35; 'next': 0.35; 'ability': 0.36; 'created': 0.36; 'except': 0.36; 'but': 0.36; 'message- id:@gmail.com': 0.36; 'received:74.125': 0.36; 'modules': 0.36; "wasn't": 0.36; 'anything': 0.36; 'client': 0.36; 'should': 0.36; 'thank': 0.36; 'enough': 0.36; 'two': 0.37; 'uses': 0.37; '(for': 0.37; 'rather': 0.37; 'things': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'called': 0.39; 'little': 0.39; 'received:192.168': 0.40; 'header:Received:5': 0.40; 'help': 0.40; 'your': 0.60; 'most': 0.61; 'free': 0.61; 'provide': 0.62; 'between': 0.63; 'great': 0.64; 'learned': 0.65; 'sound': 0.65; 'sounds': 0.71; 'trial': 0.81; '2.7.': 0.84; 'much,': 0.84; 'probable': 0.84; 'speech': 0.84; 'engines.': 0.91; 'hand.': 0.91; 'cutting': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; bh=oAwfIShq8Ezg85cxS99pJWxdscBJ07v61QuFRhC0rmY=; b=mgcCxJi2kT4XMn7GjVBbDUyoIft4DxEKnjHwlsAJpBWRTdEU8rKIGWDsTNoGAjLb27 BbX/Yz+82N9vpXUvBaLJwCVDKtUNHDwfLLDG1ezJQBFZRLhARAupq4e8CCfSy0Ov/dpp h/0AVhPaszENOWJjPaeteldq6gwnE6eTCu1qDI+uIpYXCdCIuRRVFtWqHO9e6FkoDNXh 0auMnVObLRjSrFYOGv12XUN3RlXz25L9sGt/Fa+WteRRmKI0P+RbTEBWVtNp0nzpj+H3 85ob8TmbtiQrFuf31tSO+swLl1TshzKzdTGo9DHTy7e1iuKyKaBeUORii+TAXk4LVnTR 36Mw==
Date Wed, 11 Jul 2012 09:51:38 +0200
From Vojtěch Polášek <krecoun@gmail.com>
User-Agent Mozilla/5.0 (X11; Linux i686; rv:13.0) Gecko/20120615 Thunderbird/13.0.1
MIME-Version 1.0
To python-list@python.org
Subject introduction and first question about multithreading
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2011.1341994717.4697.python-list@python.org> (permalink)
Lines 47
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1341994717 news.xs4all.nl 6888 [2001:888:2000:d::a6]:53331
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:25171

Show key headers only | View raw


Greetings,
My name is Vojta and I am blind student. I am slowly learning Python for
about 4 years and I like it alot, mostly its ability to run on various
platforms.
My primary system is Ubuntu 12.04, but I have Windows XP at hand. I am
using python 2.7. I have learned basics from the book A byte of Python
(for version 2.X) and something from Dive into Python. But most things I
learned by trial and error and thanks to solutions on stackoverflow.com.
I Don't know much about good programming concepts in Python, just in
general, so feel free to educate me about them.

I haven't created anything great yet, but I am working on a game for
blind people. It is a simple game of reaction, but I have to start with
something, my next plan is Sudoku game.
I am using Pygame for handling of sounds and keyboard events, speech
dispatcher under Linux and pyttsx under Windows to provide speech
output, numpy for sound cutting and my two little and simple modules for
providing menu system and unified interface for both speech engines.
During the development, I discovered, that I have to use multithreading
to be able to check for key presses and manage the game at the same
time. I tried threading module but this wasn't enough for me, because
function running in the separate thread needed to access variables in
the main thread at least I couldn't find the way how to do that. So I
switched to multiprocessing and started using pipes for communication
between processes. All is working well, except for one thing.
My menu module uses a loop to check for keyboard events through pygame.
I don't import pygame into my module directly, but rather pass it
through my main module like this:
menu.pygame = pygame
All was working well until I started using multiprocessing. I may have a
probable cause but I need your help.
In my main module I am running a similar loop for checking keyboard
input in separate process. When a player loses, the loop finishes and I
join the process. Then the menu module kicks in and should launch its
own loop checking for pygame keyboard events, but right after doing it
it prints:
[xcb] Unknown sequence number while processing queue
[xcb] Most likely this is a multi-threaded client and XInitThreads has
not been called
[xcb] Aborting, sorry about that.
python: ../../src/xcb_io.c:273: poll_for_event: Assertion
`!xcb_xlib_threads_sequence_lost' failed
received SigAbrt - core dumped
Are atachments allowed here? I can send you my whole code.
Please help me, if you can.
Thank you very much,
Vojta

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


Thread

introduction and first question about multithreading Vojtěch Polášek <krecoun@gmail.com> - 2012-07-11 09:51 +0200
  Re: introduction and first question about multithreading Roy Smith <roy@panix.com> - 2012-07-11 09:20 -0400

csiph-web