shell bypass 403
曾与蒿藜同雨露,한때 잡초와 쑥과 함께 비와 이슬을 나누던 곳이 이제는 소나무와 삼나무와 함께 서리와 눈을 견뎌내고 있다.终随松柏到冰霜.かつては雑草やヨモギと共に雨や露を分かち合っていたが、今では松やヒノキと共に霜や雪に耐えている。曾与蒿藜同雨露,Once sharing rain and dew with weeds and wormwood, now enduring frost and snow with pines and cypresses.终随松柏到冰霜.曾与蒿藜同雨露한때 잡초와 쑥과 함께 비와 이슬을 나누던 곳이 이제는 소나무와 삼나무와 함께 서리와 눈을 견뎌내고 있다.,终随松柏到冰霜.譖セ荳手珍阯懷酔髮ィ髴イ�檎サ磯囂譚セ譟丞芦蜀ー髴�曾与蒿藜同雨露,鏇句笌钂胯棞鍚岄洦闇诧紝缁堥殢鏉炬煆鍒板啺闇�终随松柏到冰霜.曾与蒿藜同雨露,한때 잡초와 쑥과 함께 비와 이슬을 나누던 곳이 이제는 소나무와 삼나무와 함께 서리와 눈을 견뎌내고 있다.终随松柏到冰霜.曾与蒿藜同雨露,终随松柏到冰霜.
"""Tests for asyncio/threads.py"""
import asyncio
import unittest
from contextvars import ContextVar
from unittest import mock
from test.test_asyncio import utils as test_utils
def tearDownModule():
asyncio.set_event_loop_policy(None)
class ToThreadTests(test_utils.TestCase):
def setUp(self):
super().setUp()
self.loop = asyncio.new_event_loop()
asyncio.set_event_loop(self.loop)
def tearDown(self):
self.loop.run_until_complete(
self.loop.shutdown_default_executor())
self.loop.close()
asyncio.set_event_loop(None)
self.loop = None
super().tearDown()
def test_to_thread(self):
async def main():
return await asyncio.to_thread(sum, [40, 2])
result = self.loop.run_until_complete(main())
self.assertEqual(result, 42)
def test_to_thread_exception(self):
def raise_runtime():
raise RuntimeError("test")
async def main():
await asyncio.to_thread(raise_runtime)
with self.assertRaisesRegex(RuntimeError, "test"):
self.loop.run_until_complete(main())
def test_to_thread_once(self):
func = mock.Mock()
async def main():
await asyncio.to_thread(func)
self.loop.run_until_complete(main())
func.assert_called_once()
def test_to_thread_concurrent(self):
func = mock.Mock()
async def main():
futs = []
for _ in range(10):
fut = asyncio.to_thread(func)
futs.append(fut)
await asyncio.gather(*futs)
self.loop.run_until_complete(main())
self.assertEqual(func.call_count, 10)
def test_to_thread_args_kwargs(self):
# Unlike run_in_executor(), to_thread() should directly accept kwargs.
func = mock.Mock()
async def main():
await asyncio.to_thread(func, 'test', something=True)
self.loop.run_until_complete(main())
func.assert_called_once_with('test', something=True)
def test_to_thread_contextvars(self):
test_ctx = ContextVar('test_ctx')
def get_ctx():
return test_ctx.get()
async def main():
test_ctx.set('parrot')
return await asyncio.to_thread(get_ctx)
result = self.loop.run_until_complete(main())
self.assertEqual(result, 'parrot')
if __name__ == "__main__":
unittest.main()