`

which one is thread safe?

阅读更多

quote:

 

It's not so much that they're not performed, it's that because you called a reactor API from a thread, which you are never ever ever allowed to do , you have put your program into a state where everything is completely broken, forever . Every future API call may produce bizarre, broken results, or no results, or random, inexplicable crashes.

You know, the normal way multithreaded programs work ;-).

To repeat: every API in twisted, with the sole exception of callFromThread (and by extension things which call callFromThread , like blockingCallFromThread ), is not thread safe . Unfortunately, putting in warnings for every single API would be both a code maintenance nightmare, so several users have discovered this constraint in the same way that you have, by calling an API and noticing something weird.

If you have some code which runs in a thread that needs to call a reactor API, use callFromThread or blockingCallFromThread and it will dispatch the call to the reactor thread, where everything should work smoothly. However, for stuff like timed calls, there's really no need to use threads at all, and they would needlessly complicate your program.

 

by Glyph

 

link: http://stackoverflow.com/questions/3220991/difference-between-loopingcall-and-callinthread-in-pythons-twisted

分享到:
评论

相关推荐

    Google C++ Style Guide(Google C++编程规范)高清PDF

    One way in which we keep the code base manageable is by enforcing consistency. It is very important that any programmer be able to look at another's code and quickly understand it. Maintaining a ...

    BobBuilder_app

    SortedDictionary : is the internal .net implementation which is said to be a Red/Black tree. Really big data sets! To really put the engine under pressure I did the following tests on huge data sets...

    LINQ Unleached For C Sharp(1/2)

    LINQ unique is that it enables programmers to create type-safe data access code complete with Intellisense support and compile time syntax checking. Paul Kimmel has done an excellent job of presenting...

    php_xdebug-2.2.1-5.3-vc9-nts-x86_64.dll

    although the extension is built against the most current PHP version at that time. The VCx marker tells with which compiler the extension was built, and Non-thread-safe whether ZTS was disabled....

    VclZip pro v3.10.1

    - By defining ZLIB121, VCLZip will use the latest version of ZLib which is included with the registered version. Some optimization improvements which should show some improvement in zipping and ...

    CUFFT_Library cuda fft变换 库文档

    This document describes CUFFT, the NVIDIA® CUDA™ Fast Fourier Transform (FFT) library. The FFT is a divide-and-conquer ...I Thread-safe API that can be called from multiple independent host threads

    DbfDotNet_version_1.0_Source

    In contrast it is using TypeSafe records (without boxing/unboxing) and type safe emitted code. The code is emitted only once per table. It has therefore I believe the potential to be the fastest ...

    Delphi Cookbook Third Edition

    TMonitor, thread-safe queues, and TEvent. It is also one of the most complex chapters. By the end of this chapter, the reader will be able to create and communicate with background threads, leaving ...

    Sakemail

    retrieved and SendMessage is a boolean function (maybe someone has pressed the cancel btn).- Fixed a bug when the subject field is too large.9/2/981.5.1- Fixed a bug with a message within a message ...

    Clojure.High.Performance.JVM.Programming.epub

    It has some interesting concepts and features such as immutability, gradual typing, thread-safe concurrency primitives, and macro-based metaprogramming, which makes it a great choice to create modern...

    VB编程资源大全(英文源码 API)

    If you follow the logic of the program it does teach a lot about multithreading and the necessary techniques to do this in a 'Thread Safe environmen<END><br>37,callback.zip This small project is ...

    system mechanic Activator v1.0

    04. If after all still the activator fails then try running it in Safe Mode (F8) using an Administrator account. 05. In case SysMech cannot be installed because of the message "You cannot install ...

    Objective-C的缓存框架EGOCache在iOS App开发中的使用

    EGOCache is a simple, thread-safe key value cache store. It has native support for NSString, UI/NSImage, and NSData, but can store anything that implements <NSCoding>. All cached items expire after ...

    NativeXml-master

    Fixed bugs with StrToInt which should be StrToInt64. ! Fixed bug with tag parsing where tags like "bla>bla" caused the parser to stop on the ">". Version 2.23 (02Dec2005) ! Fixed bug in entity ...

    EurekaLog_7.5.0.0_Enterprise

    27)..Fixed: Ignored unhandled thread exceptions (when EurekaLog is disabled) now triggers default OS processing (WER) 28)..Fixed: Irnored exceptions (via per-exception/events) now bring up default RTL...

    Visual C++ 编程资源大全(英文源码 DLL)

    circular_buffer_demo.zip A circular, thread-safe read/write character buffer (12KB)<END><br>67,avltree_demo.zip Describes an implementation of AVL Trees. (54KB)<END><br>68,metaclass_demo.zip ...

    Visual C++ 编程资源大全(英文源码 表单)

    39.zip Dialog which can be used as MDI child window 使用MDI子窗口的对话框(13KB)<END><br>40,40.zip Convert modal dialogs to modeless 将模式对话框转换成非模式对话框(12KB)<END><br>41,41.zip...

Global site tag (gtag.js) - Google Analytics