1414from typing import Any , Callable , TypeVar , cast
1515
1616from coverage import env
17- from coverage .config import CoverageConfig
1817from coverage .core import Core
1918from coverage .data import CoverageData
2019from coverage .debug import short_stack
@@ -60,9 +59,6 @@ class Collector:
6059 # the top, and resumed when they become the top again.
6160 _collectors : list [Collector ] = []
6261
63- # The concurrency settings we support here.
64- LIGHT_THREADS = {"greenlet" , "eventlet" , "gevent" }
65-
6662 def __init__ (
6763 self ,
6864 core : Core ,
@@ -112,8 +108,7 @@ def __init__(
112108 self .file_mapper = file_mapper
113109 self .branch = branch
114110 self .warn = warn
115- self .concurrency = concurrency
116- assert isinstance (self .concurrency , list ), f"Expected a list: { self .concurrency !r} "
111+ assert isinstance (concurrency , list ), f"Expected a list: { concurrency !r} "
117112
118113 self .pid = os .getpid ()
119114
@@ -125,37 +120,27 @@ def __init__(
125120
126121 self .concur_id_func = None
127122
128- # We can handle a few concurrency options here, but only one at a time.
129- concurrencies = set (self .concurrency )
130- unknown = concurrencies - CoverageConfig .CONCURRENCY_CHOICES
131- if unknown :
132- show = ", " .join (sorted (unknown ))
133- raise ConfigError (f"Unknown concurrency choices: { show } " )
134- light_threads = concurrencies & self .LIGHT_THREADS
135- if len (light_threads ) > 1 :
136- show = ", " .join (sorted (light_threads ))
137- raise ConfigError (f"Conflicting concurrency settings: { show } " )
138123 do_threading = False
139124
140125 tried = "nothing" # to satisfy pylint
141126 try :
142- if "greenlet" in concurrencies :
127+ if "greenlet" in concurrency :
143128 tried = "greenlet"
144129 import greenlet
145130
146131 self .concur_id_func = greenlet .getcurrent
147- elif "eventlet" in concurrencies :
132+ elif "eventlet" in concurrency :
148133 tried = "eventlet"
149134 import eventlet .greenthread
150135
151136 self .concur_id_func = eventlet .greenthread .getcurrent
152- elif "gevent" in concurrencies :
137+ elif "gevent" in concurrency :
153138 tried = "gevent"
154139 import gevent
155140
156141 self .concur_id_func = gevent .getcurrent
157142
158- if "thread" in concurrencies :
143+ if "thread" in concurrency :
159144 do_threading = True
160145 except ImportError as ex :
161146 msg = f"Couldn't trace with concurrency={ tried } , the module isn't installed."
@@ -169,7 +154,7 @@ def __init__(
169154 ),
170155 )
171156
172- if do_threading or not concurrencies :
157+ if do_threading or not concurrency :
173158 # It's important to import threading only if we need it. If
174159 # it's imported early, and the program being measured uses
175160 # gevent, then gevent's monkey-patching won't work properly.
0 commit comments