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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:26:39+00:00 2026-06-13T14:26:39+00:00

I am creating an application using Python. I first designed an API, that is

  • 0

I am creating an application using Python.

I first designed an API, that is working fine.
I am now designing my GUI. The GUI starts a Thread that is used to perform tasks against the API.

Up to now, I used the Observer pattern to handle communication through the different layers.
Basically, communication can be of two types (mainly):
– The GUI asking the Thread (and the API subsequently) to START/STOP
– The API giving information back to the Thread, that propagates to the GUI.

Here is a simple schema of the current architecture I am talking about.
One arrow means “notify”, basically.

Current Observer/Observable communication

My concern is that when the application Thread communicates, both the Gui and the API receive the message because they subscribed. Thing is, each message is only meant to be read by one of the two.

What I did to solve that is to send an message together with an ID. Each of the three elements have an id and they know whether the message is for them or now.
But I am not sure if this is the “correct” (understand nicest) way to do it. What if I have more parties in the future ?

I started thinking about some kind of manager handling communication, but It would then have to be at the top of the architecture, and I am not sure how to further organize it :s.

I am not asking for a complete solution, but mainly ideas or best practises by more experienced people 😉

I can keep handling multiple Observer pattern in this simple case.
But I was thinking about porting my code on a server. In this case, I am likely to have way more than one thread for the application, and handling API calls will become quite impossible.

Link to the code I am talking about :
GUI, ApplicationThread and Application API.

You want to look at notify and update methods.

Thx for any piece of advice !

  • 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-13T14:26:40+00:00Added an answer on June 13, 2026 at 2:26 pm

    One of the nice implementation of the observer pattern I’ve met is the signal/slot system in Qt. Objects have signals, and slots (which are actually methods) can be connected to signals. The connected slots are called when the signals are emitted.

    It seems to me that some of your problems may stem from the fact you have single communication canal in each of your objects. This forces you to have some dispatch mechanism in every update method, and makes the code quite complex.

    Taking inspiration from Qt, you could have different signals for each kind of message and recipient. The code for signal would look like :

    class Signal:
        def __init__(self):
            self.subs = []
    
        def subscribe(self, s):
            self.subs.append(s)
    
        def signal(self, *args, **kwargs):
            for s in self.subs:
                s(*args, **kwargs)
    

    For example, the gui would have a signal stop_signal and the thread a method to handle it :

    def handle_gui_stop(self):
        self.console_logger.debug("Facemovie is going to stop")
        self.my_logger.debug("Facemovie is going to stop")
        self.stop_process = True
        # ...
    

    Somewhere in the initialization code, we would tie everything together :

    gui.stop_signal.subscribe(thread.handle_gui_stop)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Python application (with GUI, using PyQt4) that gets spawned by the
I've noticed that when creating a GUI using Tkinter in python, when running the
I am creating a medium level application in Python. Everything works well now, and
I'm creating a Qt application using PyQt4 in Python. I have chosen the Dialog
I'm creating a GUI application that can monitor and manipulate a stream of messages.
I'm creating my first Python application (PyGTK) and will use a conf file. In
I have designed a small application in Python under Windows, that uses opencv. I
I'm creating an application using python and sqllite3. Are the users required to install
I'm creating an application using fabric.js , and experiencing really strange behavior. I'm adding
I am creating an application using AppleScript and I want to display a list

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.