Title: test_logging: test_config_queue_handler() race condition · Issue #93761 · python/cpython · GitHub
Open Graph Title: test_logging: test_config_queue_handler() race condition · Issue #93761 · python/cpython
X Title: test_logging: test_config_queue_handler() race condition · Issue #93761 · python/cpython
Description: The implementation of test_logging.test_config_queue_handler() uses time.sleep(0.010) as synchronization primitive. @vsajip: please don't use time.sleep() as sync primitive: https://pythondev.readthedocs.io/unstable_tests.html#don-t-use-...
Open Graph Description: The implementation of test_logging.test_config_queue_handler() uses time.sleep(0.010) as synchronization primitive. @vsajip: please don't use time.sleep() as sync primitive: https://pythondev.readt...
X Description: The implementation of test_logging.test_config_queue_handler() uses time.sleep(0.010) as synchronization primitive. @vsajip: please don't use time.sleep() as sync primitive: https://pythondev.r...
Opengraph URL: https://github.com/python/cpython/issues/93761
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"test_logging: test_config_queue_handler() race condition","articleBody":"The implementation of test_logging.test_config_queue_handler() uses time.sleep(0.010) as synchronization primitive.\r\n\r\n@vsajip: please don't use time.sleep() as sync primitive: https://pythondev.readthedocs.io/unstable_tests.html#don-t-use-sleep-as-synchronization\r\n\r\nThe test fails when the machine is busy:\r\n\r\n```\r\n$ ./python -m test test_logging -m test_config_queue_handler -F -j10 -v\r\n(...)\r\n0:00:10 load avg: 2.36 [ 48/1] test_logging failed (1 failure)\r\ntest_config_queue_handler (test.test_logging.ConfigDictTest.test_config_queue_handler) ... FAIL\r\n\r\n======================================================================\r\nFAIL: test_config_queue_handler (test.test_logging.ConfigDictTest.test_config_queue_handler)\r\n----------------------------------------------------------------------\r\nTraceback (most recent call last):\r\n File \"/home/vstinner/python/main/Lib/test/test_logging.py\", line 3647, in test_config_queue_handler\r\n self.do_queuehandler_configuration(qspec, lspec)\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n File \"/home/vstinner/python/main/Lib/test/test_logging.py\", line 3621, in do_queuehandler_configuration\r\n self.assertEqual(data, ['foo', 'bar', 'baz'])\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\nAssertionError: Lists differ: [] != ['foo', 'bar', 'baz']\r\n\r\nSecond list contains 3 additional elements.\r\nFirst extra element 0:\r\n'foo'\r\n\r\n- []\r\n+ ['foo', 'bar', 'baz']\r\n\r\n----------------------------------------------------------------------\r\nRan 1 test in 0.466s\r\n\r\nFAILED (failures=1)\r\n```\r\n\r\nExtract of the test:\r\n\r\n```\r\n delay = 0.01\r\n try:\r\n self.apply_config(cd)\r\n qh = logging.getHandlerByName('ah')\r\n self.assertEqual(sorted(logging.getHandlerNames()), ['ah', 'h1'])\r\n self.assertIsNotNone(qh.listener)\r\n qh.listener.start()\r\n # Need to let the listener thread get started\r\n time.sleep(delay)\r\n logging.debug('foo')\r\n logging.info('bar')\r\n logging.warning('baz')\r\n # Need to let the listener thread finish its work\r\n time.sleep(delay)\r\n with open(fn, encoding='utf-8') as f:\r\n data = f.read().splitlines()\r\n self.assertEqual(data, ['foo', 'bar', 'baz'])\r\n finally:\r\n if qh:\r\n qh.listener.stop()\r\n h = logging.getHandlerByName('h1')\r\n if h:\r\n self.addCleanup(closeFileHandler, h, fn)\r\n else:\r\n self.addCleanup(os.remove, fn)\r\n```","author":{"url":"https://github.com/vstinner","@type":"Person","name":"vstinner"},"datePublished":"2022-06-13T09:16:44.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/93761/cpython/issues/93761"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:feec7804-a6e7-b2bc-91a6-1427899701b3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A63A:247F51:17E565E:2028B21:6969ACD6 |
| html-safe-nonce | e8bbb7a16273a1e62f35d4e196d4d1323693aa87e6b51936404df6547a969087 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNjNBOjI0N0Y1MToxN0U1NjVFOjIwMjhCMjE6Njk2OUFDRDYiLCJ2aXNpdG9yX2lkIjoiNDkyNjAyNDA2MzcyNTk3MjY5NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 74c795f19ba286bb77183b03c5e75700c2bb7177512c6634319312456b26f3aa |
| hovercard-subject-tag | issue:1269146229 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/93761/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a826fa525b6934f7535db3531b0e8a232144c8e4aa00df90a575021f0663f2ae/python/cpython/issues/93761 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a826fa525b6934f7535db3531b0e8a232144c8e4aa00df90a575021f0663f2ae/python/cpython/issues/93761 |
| og:image:alt | The implementation of test_logging.test_config_queue_handler() uses time.sleep(0.010) as synchronization primitive. @vsajip: please don't use time.sleep() as sync primitive: https://pythondev.readt... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | vstinner |
| hostname | github.com |
| expected-hostname | github.com |
| None | 24c4c97a2d520cb286b35e1a4c22d7a4df3c26a2fa28dd7cdf0e65db327b4de7 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 124667f43168afb6c9c03b7c02eb5b1d2e1be3d9 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width