File tree Expand file tree Collapse file tree 3 files changed +23
-1
lines changed
Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -558,7 +558,9 @@ def _perform_urllib_http_request(
558558 f"Invalid proxy detected: { self .proxy } must be a str value"
559559 )
560560
561- resp : HTTPResponse = urlopen (req , context = self .ssl )
561+ resp : HTTPResponse = urlopen (
562+ req , context = self .ssl , timeout = self .timeout
563+ )
562564 charset = resp .headers .get_content_charset ()
563565 body : str = resp .read ().decode (charset ) # read the response body here
564566 return {"status" : resp .code , "headers" : resp .headers , "body" : body }
Original file line number Diff line number Diff line change 22import logging
33import re
44import threading
5+ import time
56from http import HTTPStatus
67from http .server import HTTPServer , SimpleHTTPRequestHandler
78from typing import Type
@@ -90,6 +91,13 @@ def _handle(self):
9091 self .wfile .close ()
9192 return
9293
94+ if pattern == "timeout" :
95+ time .sleep (2 )
96+ self .send_response (200 )
97+ self .wfile .write ("""{"ok":true}""" .encode ("utf-8" ))
98+ self .wfile .close ()
99+ return
100+
93101 if request_body and "cursor" in request_body :
94102 page = request_body ["cursor" ]
95103 pattern = f"{ pattern } _{ page } "
Original file line number Diff line number Diff line change 11import asyncio
22import re
3+ import socket
34import unittest
45
56import slack .errors as err
@@ -211,3 +212,14 @@ async def test_token_param_async(self):
211212 self .assertIsNone (resp ["error" ])
212213 with self .assertRaises (err .SlackApiError ):
213214 await client .users_list ()
215+
216+ def test_timeout_issue_712 (self ):
217+ client = WebClient (base_url = "http://localhost:8888" , timeout = 1 )
218+ with self .assertRaises (socket .timeout ):
219+ client .users_list (token = "xoxb-timeout" )
220+
221+ @async_test
222+ async def test_timeout_issue_712_async (self ):
223+ client = WebClient (base_url = "http://localhost:8888" , timeout = 1 , run_async = True )
224+ with self .assertRaises (asyncio .exceptions .TimeoutError ):
225+ await client .users_list (token = "xoxb-timeout" )
You can’t perform that action at this time.
0 commit comments