use of yield

Asked by nside

Hello,

I'm just curious: why do you use yield so often? For example in this statement (taken from testlib.py):
 client = yield onConn

Thanks!

Question information

Language:
English Edit question
Status:
Solved
For:
txAMQP Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Launchpad Janitor (janitor) said :
#1

This question was expired because it remained in the 'Open' state without activity for the last 15 days.

Revision history for this message
Esteve Fernandez (esteve) said :
#2

Sorry for not having replied to this question earlier, I didn't set an answer contact in Launchpad and didn't notice you asked a question.

The reason for using yield is that tests use the inlineCallbacks idiom (http://twistedmatrix.com/documents/8.1.0/api/twisted.internet.defer.html#inlineCallbacks) which saves you from having to define a callback function and makes code look as if it were sequential.

Revision history for this message
Launchpad Janitor (janitor) said :
#3

This question was expired because it remained in the 'Open' state without activity for the last 15 days.

Revision history for this message
Esteve Fernandez (esteve) said :
#4

I marked the question as solved, please reopen it if you feel the given answer is not complete.