简体   繁体   English

PHP请求串行而不是并行处理

[英]PHP requests processing in serial not parallel

I wrote a page ( cron.php ) that uses the imap library to connect to a mailbox, parse messages, and store them in a database, then echo s the results in json. 我编写了一个页面( cron.php ),该页面使用imap库连接到邮箱,解析消息并将其存储在数据库中,然后在json中echo显结果。 I have a few dozen mailboxes that I need to run this same process for, and so I put together a page ( mailboxes.php ) that lists all these accounts, each with a button that when clicked, essentially hits cron.php via AJAX and parses the json response to update the page when the process is completed. 我有几十个邮箱需要运行相同的过程,因此,我整理了一个页面( mailboxes.php ),其中列出了所有这些帐户,每个帐户都有一个按钮,当单击该按钮时,它们实际上是通过AJAX cron.php 。该过程完成后,解析json响应以更新页面。

I've noticed however that if I click each of these boxes, they return as if running serially, not in parallel. 但是,我注意到,如果单击这些框中的每个框,它们的返回就像串行运行一样,而不是并行运行。 Is there a configuration option someplace that might explain this? 是否有某个配置选项可以解释这一点?

Yeah you need to use session_write_close() on the cron.php file. 是的,您需要在cron.php文件上使用session_write_close() session_write_close session_write_close

Are you using sessions? 您正在使用会话吗? Every time you run session_start for given session, it is being locked, until the script finishes, or the session is being 'detached'. 每次为给定会话运行session_start ,它将被锁定,直到脚本完成或该会话被“分离”为止。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM