blob: 7cc60db22d62125e13ca25b18273b56782e48b44 [file] [log] [blame]
Illyoung Choia9d2c2c2019-07-12 13:29:42 -07001# Copyright 2019-present Open Networking Foundation
2#
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
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
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.
14
15from __future__ import absolute_import
16import atexit
17from .dummy_server import stop as server_stop
18
19dummy_servers = {}
20
21
22def cleanup_dummy_servers():
23 for pid in dummy_servers:
24 s = dummy_servers[pid]
25 server_stop(s)
26 del dummy_servers[pid]
27
28
29def register_dummy_server_cleanup(s):
30 if s.pid not in dummy_servers:
31 dummy_servers[s.pid] = s
32
33
34def unregister_dummy_server_cleanup(s):
35 if s.pid in dummy_servers:
36 del dummy_servers[s.pid]
37
38
39atexit.register(cleanup_dummy_servers)