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

  • Home
  • SEARCH
  • 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 8990183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:26:42+00:00 2026-06-15T22:26:42+00:00

I am new to twisted and python, I am reading twisted python. registering call

  • 0

I am new to twisted and python, I am reading twisted python.

registering call

reactor.callLater(_interval, self.count, *args)

I have created Countdown class and it contains count function, I am calling it three time

reactor.callWhenRunning(Countdown().count, 1)
reactor.callWhenRunning(Countdown().count, 2)
reactor.callWhenRunning(Countdown().count, 3)

with different time interval, and I need to stop reactor when all call is finished. So is in twisted API have some method to know all call is completed.

My Code is

class Countdown(object):

    counter = 5

    def count(self, *args):
    _interval = args[0]
        name = args[1]
        if self.counter == 0 and name == "Third Call":
            reactor.stop()
        elif self.counter == 0:
        print name, " Finished..!"
        else:
            print self.counter, '...'
            self.counter -= 1
            reactor.callLater(_interval, self.count, *args)

from twisted.internet import reactor

reactor.callWhenRunning(Countdown().count, 1, "First Call")
reactor.callWhenRunning(Countdown().count, 2, "Second Call")
reactor.callWhenRunning(Countdown().count, 3, "Third Call")

print 'Start!'
reactor.run()
print 'Stop!'

Now I am using
if self.counter == 0 and name == “Third Call”:
to prevent my all counter process is finished. So now I need to know, is there in twisted have any built in method to know all call is finished or my all counter call is finished.

  • 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-15T22:26:43+00:00Added an answer on June 15, 2026 at 10:26 pm

    Twisted has an API for working with a list of events: DeferredList http://twistedmatrix.com/documents/current/core/howto/defer.html#auto8

    Here is a small example how this might work:

    from twisted.internet import defer 
    from twisted.internet import reactor
    
    
    def delayedFunction(dF):
        print('I was called')
        dF.success(True)
    
    class Counter(object):
        def timeOffsetExecute(self,delay):
            dF = defer.Deferred()
            reactor.callLater(delay,delayedFunction,dF)
            return dF
    
    def onAllResult(val):
        print 'All delayed functions called'
        reactor.stop()
    
    cp = Counter()
    
    dl = defer.DeferredList([cp.timeOffsetExecute(1), cp.timeOffsetExecute(3), cp.timeOffsetExecute(9)], consumeErrors=True)
    dl.addCallback(onAllResult)
    
    reactor.run()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to Python, Twisted , and Trial... and for Windows users the setup
I have a game server written in python and twisted, and an old game
I have a server application written in python using twisted and I'd like to
I am new to Python programming and have covered sockets a bit. I couldn't
Im new to Twisted. Why is it printing render() twice? I know if I
I tried urllib{2}, pycurl and I'm looking at twisted's new http client. But: I
New to PHP and MySQL, have heard amazing things about this website from Leo
I'm currently working on a Python/Twisted project which is to be distributed and tested
I am a newcomer to the Python and Twisted game so excuse the ignorance
So I'm writing yet another Twisted based daemon. It'll have an xmlrpc interface as

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.