国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

How to do asynchronous file operations?

bosun

I am building a websocket service based on workermanand will like to fetch the content of a bunch of files. Doind this one after the other will take a lot of time, so I am looking for a way such that I can fetch these 10 files asynchrnously withou waiting for each to finish and then wait for all of them in the end.

I've been looking around the documentation but didn't see anything around concerning this.
Also, what is the impact of using file_get_contents, which is a blocking function, inside workerman?

Thank you.

716 2 0
2個回答

chaz6chez

You could give the aio extension a shot, fire up some aio get requests in one process, and then block and wait for results

  • chaz6chez 2023-08-22

    This method will hold up the current process, but it can also get the job done, unless you want it to run without blocking the current process.

nitron

if u fetch files via http ,u can use this
http://wtbis.cn/doc/workerman/components/workerman-http-client.html
file_get_contents will block current thread

  • bosun 2023-08-22

    The files are residing locally on the server and not on another server, so, using an http client is not beneficial for this task.

年代過于久遠,無法發(fā)表回答
??