小编Car*_*ari的帖子

pyzmq中的套接字句柄泄漏?

嗨好StackOverflow的人.

我正在使用pyzmq并且我有一些长时间运行的进程,这导致发现套接字句柄处于打开状态.我已将违规代码缩小到以下内容:

import zmq

uri = 'tcp://127.0.0.1'
sock_type = zmq.REQ
linger = 250

# Observe output of lsof -p <pid> here and see no socket handles

ctx = zmq.Context.instance()
sock = ctx.socket(sock_type)
sock.setsockopt(zmq.LINGER, linger)
port = sock.bind_to_random_port(uri)

# Observe output of lsof -p <pid> here and see many socket handles

sock.close()  # lsof -p <pid> still showing many socket handles
ctx.destroy()  # Makes no difference
Run Code Online (Sandbox Code Playgroud)

pyzmq版本是pyzmq-13.1.0

pyzmq中有一个错误,或者我做错了什么.我希望你能帮帮我!!

谢谢!

python zeromq resource-leak handle-leak pyzmq

7
推荐指数
1
解决办法
680
查看次数

ElasticSearch嵌套查询与过滤器

好吧,对于你们这些超级棒的ElasticSearch专家来说,这个可能不会太难.我有这个嵌套查询,我希望嵌套查询在非嵌套字段(状态)上进行过滤.我不知道把过滤器放在哪里.我试过把它放在一个查询中(下面),但那并没有给我正确的结果.你能帮我吗?

{
  "aggs": {
    "status": {
      "terms": {
        "field": "status",
        "size": 0
      }
    }
  },
  "filter": {
    "nested": {
      "path": "participants",
      "filter": {
        "bool": {
          "must": [
            {
              "term": {
                "user_id": 1
              }
            },
            {
              "term": {
                "archived": false
              }
            },
            {
              "term": {
                "has_unread": true
              }
            }
          ]
        }
      }
    }
  },
  "query": {
    "filtered": {
      "filter": {
        "bool": {
          "must_not": [
            {
              "term": {
                "status": 8
              }
            }
          ]
        }
      }
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

nested elasticsearch

5
推荐指数
1
解决办法
8796
查看次数