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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:34:36+00:00 2026-05-28T20:34:36+00:00

For a simple chat program i use a c lib that is wrapped via

  • 0

For a simple chat program i use a c lib that is wrapped via boost::python.

A simple GUI is written using PyQT. Receiving messages is done via a blocking call to
said lib. For the GUI to refresh independently the communication part is in a QThread.

While i would assume the GUI and the communication to be independent, the GUI is extremely unresponsive and seems to only update when messages are coming in.

#!/usr/bin/env python

import sys

from PyQt4.QtCore import *
from PyQt4.QtGui import *

import pynetcom2
import time


class NetCom(QThread):

  def __init__(self):
    QThread.__init__(self)
    self.client = pynetcom2.Client()
    self.client.init('127.0.0.1', 4028)
    self.client.provide('myChat', 1)
    self.client.subscribe('myChat', 100)

  def run(self):
    while (1):
      print "Waiting for message..."
      text = self.client.recvStr('myChat', True)
    return



class Netchat(QMainWindow):

    def __init__(self, argv):

        if (len(argv) != 2):
            print "Usage: %s <nickname>" %(argv[0])
            sys.exit(1)
        self.nickname = argv[1]
        print "Logging in with nickname '%s'" %(self.nickname)

        super(Netchat, self).__init__()
        self.setupUI()

        rect = QApplication.desktop().availableGeometry()
        self.resize(int(rect.width() * 0.3), int(rect.height() * 0.6))
        self.show()

        self.com = NetCom()
        self.com.start()

    def setupUI(self):
        centralWidget = QWidget()
        self.setCentralWidget(centralWidget)

        self.testList = QListWidget()

        mainLayout = QHBoxLayout()
        mainLayout.addWidget(self.testList)
        centralWidget.setLayout(mainLayout)

if __name__ == "__main__":
  app = QApplication(sys.argv)
  netchat = Netchat(sys.argv)
  app.exec_()
  • 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-28T20:34:37+00:00Added an answer on May 28, 2026 at 8:34 pm

    This might be caused by the infamous Global Interpreter Lock (GIL). Python does not allow two threads to execute Python code at the same time. In your C function, you have to explicitly release and re-acquire the GIL if you want your GUI code to run in parallel.

    This is explained in the Python C API documentation: Thread State and the Global Interpreter Lock.

    It boils down to using the following macros in your C extension:

    Py_BEGIN_ALLOW_THREADS
    
    // Your expensive computation goes here.
    
    Py_END_ALLOW_THREADS
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have simple chat program using WCF service. One service use for server and
I'm making a simple cross platform chat program. I'm using wXWidgets for the GUI
I am trying to implement a simple chat program in linux using bsd sockets.
I'm creating a very simple Java chat program, using the Java TCP sockets. I'm
I am trying to create a simple chat program using Java. I have create
I would like to create a simple chat room like GUI interface that will
Hey guys, I was working on a simple chat program to brush up on
I want to develop simple Serverless LAN Chat program just for fun. How can
I am working on a simple chat application using a System.Windows.Forms.WebBrowser Control to display
I got an assessment to write a simple chat client for Linux using ncurses.

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.