私は、MessageQueuesを取得するためにposixリアルタイム拡張をラップするPythonモジュールを使用しています。10個以上のmqueueを作成できません
これはこれはOSError: This process already has the maximum number of files open
を報告する前に、約10 MQSを作成するPythonコード
#!/usr/bin env python
import uuid
import posix_ipc
import time
def spawn():
return posix_ipc.MessageQueue("/%s" % uuid.uuid4(), flags=posix_ipc.O_CREAT)
i = 0
while True:
i += 1
spawn()
print(i)
である私は、MQの制限とRLIMITに見て、彼らはすべて非常に高く設定されていることを確認しました。例えば。
fs.file-max = 2097152
fs.mqueue.msg_max = 1000
fs.mqueue.queues_max = 1000
また、特権ユーザーの場合でも約10のキューしか作成されません。
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <errno.h>
#include <mqueue.h>
#define handle_error(msg) \
do { perror(msg); exit(EXIT_FAILURE); } while (0)
int main(int argc, char **argv)
{
mqd_t mq;
struct mq_attr attr;
char buffer[1024 + 1];
int must_stop = 0;
/* initialize the queue attributes */
attr.mq_flags = 0;
attr.mq_maxmsg = 10;
attr.mq_msgsize = 1024;
attr.mq_curmsgs = 0;
/* create the message queue */
int count = 0;
char name[5];
while (1) {
sprintf(name, "/%d", count);
mq = mq_open(name, O_CREAT | O_RDONLY, 0644, &attr);
if (mq == (mqd_t) -1)
handle_error("mq_open");
count++;
}
return 0;
}
(gcc -lrt test.c
でコンパイルする) を次のようにリアルタイム拡張を使用して同等のCは、直接である。しかし、これは私だけ一度にオープン20 MQSを取得します。現実的には、一度に何百人も開いてもいいと思っています。
誰でも意見や提案がありますか?
EDIT:Cバージョンのエラーチェックの改善。まだ最大です。
Cプログラムのエラーチェックが正しくない - 'mq_open'リターン'(mqd_t)場合_errno_チェック-1' 。 – pilcrow
@pilcrow固定しました –