|
3 | 3 | import glob
|
4 | 4 | import os
|
5 | 5 | import re
|
| 6 | +import threading |
6 | 7 | import warnings
|
7 | 8 |
|
8 | 9 | try:
|
9 | 10 | from importlib import import_module
|
10 | 11 | except ImportError:
|
11 | 12 | import_module = __import__
|
12 | 13 |
|
| 14 | +try: |
| 15 | + from importlib import reload |
| 16 | +except ImportError: |
| 17 | + pass |
| 18 | + |
13 | 19 | from distutils.version import LooseVersion
|
14 | 20 |
|
15 | 21 | import pytest
|
|
22 | 28 | from pandas.compat import (map, zip, StringIO, string_types, BytesIO,
|
23 | 29 | is_platform_windows, PY3)
|
24 | 30 | from pandas.io.common import URLError, urlopen, file_path_to_url
|
| 31 | +import pandas.io.html |
25 | 32 | from pandas.io.html import read_html
|
26 | 33 | from pandas._libs.parsers import ParserError
|
27 | 34 |
|
@@ -931,3 +938,24 @@ def test_same_ordering():
|
931 | 938 | dfs_lxml = read_html(filename, index_col=0, flavor=['lxml'])
|
932 | 939 | dfs_bs4 = read_html(filename, index_col=0, flavor=['bs4'])
|
933 | 940 | assert_framelist_equal(dfs_lxml, dfs_bs4)
|
| 941 | + |
| 942 | +class ErrorThread(threading.Thread): |
| 943 | + def run(self): |
| 944 | + try: |
| 945 | + super(ErrorThread, self).run() |
| 946 | + except Exception as e: |
| 947 | + self.err = e |
| 948 | + else: |
| 949 | + self.err = None |
| 950 | + |
| 951 | +@pytest.mark.slow |
| 952 | +def test_importcheck_thread_safety(): |
| 953 | + reload(pandas.io.html) |
| 954 | + filename = os.path.join(DATA_PATH, 'valid_markup.html') |
| 955 | + helper_thread1 = ErrorThread(target = read_html, args = (filename,)) |
| 956 | + helper_thread2 = ErrorThread(target = read_html, args = (filename,)) |
| 957 | + helper_thread1.start() |
| 958 | + helper_thread2.start() |
| 959 | + while(helper_thread1.is_alive() or helper_thread2.is_alive()): |
| 960 | + pass |
| 961 | + assert None == helper_thread1.err == helper_thread2.err |
0 commit comments