Skip to content

Commit

Permalink
change request post handler to async (#821)
Browse files Browse the repository at this point in the history
* change request post handler to async

* version
  • Loading branch information
noO0oOo0ob authored Jan 22, 2024
1 parent 407f1ea commit 94d5536
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions lyrebird/mock/handlers/handler_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,9 @@ def generator():
self.server_resp_time = time.time()
yield _resp_data[ i * size : (i+1) * size ]
finally:
self.update_client_resp_time()
def request_post_handler():
self.update_client_resp_time()
application.server['task'].add_task('request_post', request_post_handler)
return generator

def _generator_stream(self):
Expand All @@ -259,11 +261,13 @@ def generator():
self.server_resp_time = time.time()
yield item
finally:
self.response.data = b''.join(buffer)
DataHelper.origin2flow(self.response, output=self.flow['response'], chain=self.response_chain)
def request_post_handler():
self.response.data = b''.join(buffer)
DataHelper.origin2flow(self.response, output=self.flow['response'], chain=self.response_chain)

self.update_client_resp_time()
upstream.close()
self.update_client_resp_time()
upstream.close()
application.server['task'].add_task('request_post', request_post_handler)
return generator

def update_response_headers_code2flow(self, output_key='response'):
Expand Down
2 changes: 1 addition & 1 deletion lyrebird/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
IVERSION = (2, 23, 5)
IVERSION = (2, 24, 0)
VERSION = ".".join(str(i) for i in IVERSION)
LYREBIRD = "Lyrebird " + VERSION

0 comments on commit 94d5536

Please sign in to comment.