From 39bed0eb37e5774a19872fec066f176b22609caa Mon Sep 17 00:00:00 2001 From: Chris Angelico Date: Fri, 6 Dec 2024 21:16:01 +1100 Subject: [PATCH] Take advantage of the ability to await send() --- modules/http/chan_commands.pike | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/modules/http/chan_commands.pike b/modules/http/chan_commands.pike index b2fef5a1..52c748a7 100644 --- a/modules/http/chan_commands.pike +++ b/modules/http/chan_commands.pike @@ -138,17 +138,16 @@ __async__ mapping(string:mixed) http_request(Protocols.HTTP.Server.Request req) vars["$$"] = u->display_name; vars["{uid}"] = (string)person->uid; //Will be "0" if no UID known array capture = ({ }); - c->_send_with_catch(person, message, vars, ([ + await(c->_send_with_catch(person, message, vars, ([ "users": (["": (string)person->uid]), "simulate": lambda(string m) {capture += ({m});}, - ])); + ]))); mapping stats = ([]); int num = (int)req->variables->num || 100; - for (int i = 0; i < num; ++i) c->_send_with_catch(person, message, vars, ([ + for (int i = 0; i < num; ++i) await(c->_send_with_catch(person, message, vars, ([ "users": (["": (string)person->uid]), "simulate": lambda(string m) {stats[m]++;}, - ])); - sleep(2); //Hack upon hack: Wait till it's probably done sending.*/ + ]))); array lines = indices(stats), counts = -values(stats)[*]; sort(counts, lines); int tot = 0;