1
# Copyright 2014-2015 MongoDB, Inc.
3
# Licensed under the Apache License, Version 2.0 (the "License");
4
# you may not use this file except in compliance with the License.
5
# You may obtain a copy of the License at
7
# http://www.apache.org/licenses/LICENSE-2.0
9
# Unless required by applicable law or agreed to in writing, software
10
# distributed under the License is distributed on an "AS IS" BASIS,
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
# See the License for the specific language governing permissions and
13
# limitations under the License.
15
"""Test the monitor module."""
19
from functools import partial
23
from pymongo.periodic_executor import _EXECUTORS
24
from test import unittest, port, host, IntegrationTest
25
from test.utils import single_client, one, connected, wait_until
28
def unregistered(ref):
30
return ref not in _EXECUTORS
33
class TestMonitor(IntegrationTest):
34
def test_atexit_hook(self):
35
client = single_client(host, port)
36
executor = one(client._topology._servers.values())._monitor._executor
39
# The executor stores a weakref to itself in _EXECUTORS.
40
ref = one([r for r in _EXECUTORS.copy() if r() is executor])
45
wait_until(partial(unregistered, ref), 'unregister executor',
49
if __name__ == "__main__":