我使用DRF扩展来获取模型的se json列表,并且我可以使用debug-toolbar
该GET
请求进行调试,但是我如何调试POST
和PUT
请求?
我有这个用于调试模式的设置:
INSTALLED_APPS += ('debug_toolbar',)
MIDDLEWARE_CLASSES += ('debug_toolbar.middleware.DebugToolbarMiddleware',)
DEBUG_TOOLBAR_PATCH_SETTINGS = False
INTERNAL_IPS = (
'127.0.0.1'
)
Run Code Online (Sandbox Code Playgroud)
现在,当我Intercept redirects
在调试工具栏中尝试时,它不会显示我的工具栏POST
.
我正在尝试使用并发.futures.ThreadPoolExecutor 模块并行运行类方法,我的代码的简化版本几乎如下:
class TestClass:
def __init__(self, secondsToSleepFor):
self.secondsToSleepFor = secondsToSleepFor
def testMethodToExecInParallel(self):
print("ThreadName: " + threading.currentThread().getName())
print(threading.currentThread().getName() + " is sleeping for " + str(self.secondsToSleepFor) + " seconds")
time.sleep(self.secondsToSleepFor)
print(threading.currentThread().getName() + " has finished!!")
with concurrent.futures.ThreadPoolExecutor(max_workers = 2) as executor:
futuresList = []
print("before try")
try:
testClass = TestClass(3)
future = executor.submit(testClass.testMethodToExecInParallel)
futuresList.append(future)
except Exception as exc:
print('Exception generated: %s' % exc)
Run Code Online (Sandbox Code Playgroud)
如果我执行这段代码,它的行为似乎就像它预期的那样。但是,如果我犯了一个错误,例如在“testMethodToExecInParallel”中指定了错误数量的参数,例如:
def testMethodToExecInParallel(self, secondsToSleepFor):
Run Code Online (Sandbox Code Playgroud)
然后仍然将函数提交为:
future = executor.submit(testClass.testMethodToExecInParallel)
Run Code Online (Sandbox Code Playgroud)
或者尝试在“testMethodToExecInParallel”方法中的打印语句内将字符串对象与整数对象连接(不使用 str(.) ):
def testMethodToExecInParallel(self):
print("ThreadName: " + threading.currentThread().getName())
print("self.secondsToSleepFor: …
Run Code Online (Sandbox Code Playgroud)