def group(self, name, block=True):
"""
Queue's an NNTPRequest for processing and returns a call
to GROUP (fetching details on it specifically)
If block is not set to true, then it is up to the calling
application to monitor the request until it's complete.
Since the Request Object is inherited from a gevent.Event()
object, one can easily check the status with the ready()
call or, wait() if they want to block until content is ready.
See http://www.gevent.org/gevent.event.html#module-gevent.event
for more details.
To remain thread-safe; it's recommended that you do not change
any of the response contents or articles contents prior to
it's flag being set (marking completion)
"""
# Push request to the queue
request = NNTPConnectionRequest(actions=[
# Append list of NNTPConnection requests in a list
# ('function, (*args), (**kwargs) )
('group', (name, ), {}),
])
# Append to Queue for processing
self.put(request)
# We'll know when our request has been handled because the
# request is included in the response.
if block:
request.wait()
# Simplify things by returning just the response object
# instead of the request
return request.response[0]
# We aren't blocking, so just return the request object
return request
评论列表
文章目录