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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:40:52+00:00 2026-05-30T17:40:52+00:00

This question might be unclear – if so, that probably because I’m not entirely

  • 0

This question might be unclear – if so, that probably because I’m not entirely shure how to ask the question – but here goes:

I have a Python class from which I would like to call a function.

The class does not have access to the data that the function should operate on – basically, I would like the class to send a message to another process, that calls the function. Something like:

from multiprocessing import Process

class Foo():
   def bar(phonenumber):
      do_something()
      send_message(phonenumber)

def daemon(data, phonenumber):
   while nothing_receivied(phonenumber):
      do_nothin()
      also_do_not_consume_too_much_CPU()
   if message_received(phonenumber):
      function(data)

p = Process(target=daemon, args=(data, phonenumber))
p.start()
p.join()

calling Foo.bar(phonenumber) should then have the extra effect that function is performed on data – how is this achievable?

Cheers!

  • 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-30T17:40:53+00:00Added an answer on May 30, 2026 at 5:40 pm

    If you specifically are trying to use the multiprocessing module, you should probably take a look into using a Queue/Pipe. http://docs.python.org/library/multiprocessing.html#pipes-and-queues

    The part of your daemon code where you want to sit and do nothing while not consuming too much CPU is the point where it would try and get an item from the queue, or poll the pipe for data and block until something is ready. The other side of the queue or pipe would simply put data into the queue which fills the role of your send_message concept.

    If you want a more robust asynchronous solution, you should also check out the Twisted libraries: http://twistedmatrix.com/trac/

    This would allow you to define a service at a higher level that has an event loop with handlers to process incoming connections.

    And lastly, if you just wanted a simple solution all in the same script and not anything network-based, you could easily just use the threading module: http://docs.python.org/library/threading.html . And use Queue.Queue for the daemon to block on with a get(), and send_message() doing a put()

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

Sidebar

Related Questions

This question might not seem programming related at first, but let me explain. I'm
This question might be kind of elementary, but here goes: I have a SQL
This question might be specific to SoThink Video Encoder v2.5, but it might not.
I realize this question might not be that programming related, and that it by
This question might not belong here, and since this is related to HTML and
I know that this question might have been asked like 100 times, but, believe
This question might seem really silly to most of the enlightened folks here. But
This question might sound a bit stupid but here it goes. I have two
This question might be a bit sketchy because I do not have the code
This question might sound fool, because I know there are bunch of frameworks that

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.