You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a code using func_timeout to limit time out of process = 0.1
Example
class Solution
def process_timeout(self, s: str):
// run some task take time
return {
"province": province,
"district": district,
"ward": original_ward, # Duy Fix khac dau
}
def process(self, s: str):
res = self.process_timeout(s)
return res
In main function:
🙋♂️ Happy case:
In this case func_timeout run ok . It will limit timeout in 0.1s
__main___
solution = Solution()
for i in Range(10):
try:
res = func_timeout(0.1,solution.process,args=(s,))
except FunctionTimedOut:
return {
"province": "EXCEPTION",
"district": "EXCEPTION",
"ward": "EXCEPTION"
}
👎👎 Bad case change liitle logic :👎
I move function func_timeout to inside method process. It dont run or call thread to set timeout. It can't kill thread after 0.1s.
class Solution:
// same sample code
....
def process(self, s: str):
try:
res = func_timeout(0.1,self.process_timeout,args=(s,))
return res
except FunctionTimedOut:
return {
"province": "EXCEPTION",
"district": "EXCEPTION",
"ward": "EXCEPTION"
}
__ main __
solution = Solution()
for i in Range(10):
res = solution.process()
😑
Please help me answer above situation ? thanks 🙏
The text was updated successfully, but these errors were encountered:
I have a code using func_timeout to limit time out of process = 0.1
Example
In main function:
🙋♂️ Happy case:
In this case func_timeout run ok . It will limit timeout in 0.1s
👎👎 Bad case change liitle logic :👎
I move function func_timeout to inside method process. It dont run or call thread to set timeout. It can't kill thread after 0.1s.
😑
Please help me answer above situation ? thanks 🙏
The text was updated successfully, but these errors were encountered: