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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:43:55+00:00 2026-05-25T06:43:55+00:00

After reading the documentation and a few use cases. The question arose how to

  • 0

After reading the documentation and a few use cases. The question arose how to use a chain of Callbacks. More precisely how to transfer data between Callbacks

Here is the code:

d = defer.Deferred()
d.addCallback(self.min_active_stack)
d.addCallback(self.min_normalization)
d.addCallback(self.insert_db)
d.callback(0)

def min_active_stack(self,d):
    ...
    return self.dbconn.runQuery(sql_query)

def min_normalization(self,min):
    ...
    return min[0][0]+self.x

def insert_db(self,min_norm):
    ...
    return self.dbconn.runQuery(sql_query)

First, in min_active_stack I do request to db. In min_normalization I process the data. And insert_db on the processed data I do have one request to the db.

In this case, data is transmitted through the chain and it’s simple.
But what if in the middle of the chain need to run more then a Callback.

d = defer.Deferred()
d.addCallback(self.min_active_stack)
d.addCallback(self.stack_shift)
d.addCallback(self.min_normalization)
d.addCallback(self.insert_db)
d.callback(0)

def stack_shift(self, d):
    return self.dbconn.runQuery(query)

In stack_shift are not used any external data, but it should be run after min_active_stack and before insert_db. It turns out that in min_normalization comes from deferred stack_shift instead of min_active_stack.

For myself, I solved this problem by adding a line in stack_shiftt:

self.temp=d   

And use self.temp in min_normalization.

But as far as the right decision?

  • 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-25T06:43:55+00:00Added an answer on May 25, 2026 at 6:43 am

    I actually don’t understand the problem. Why you can’t just pass result from min_active_stack() through stack_shift() into min_normalization()?

    def stack_shift(res):
        # do something usefull
        return res
    

    Or since it looks like you want to do something asynchronous in stack_shift, the Deferred equivalent:

    def stack_shift(res):
        d = runQuery(query)
        d.addCallback(lambda ignored: res)
        return d
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a few questions about this after reading the iPhone documentation on it:
I'm struggling to implement ACL in CakePHP. After reading the documentation in the cake
After reading this question , I was reminded of when I was taught Java
After reading a bit more about how Gnutella and other P2P networks function, I
After reading the answers to the question Calculate Code Metrics I installed the tool
After reading the documentation (http://stw.castleproject.org/Windsor.Installers.ashx) I've found a strange part: Although technically it's OK
I am learning Spring-MVC in my first project here. After reading the documentation on
After reading documentation on paypals developers website for quite a while, I've come to
I'm new to Apache Solr. Even after reading the documentation part, I'm finding it
After reading the Head First Design Patterns book and using a number of other

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.