title: Asynchronous data through Bloomberg's new data API (COM v3) with Python?
body: <p>Does anyone know how to get asynchronous data through Bloomberg's new data API (COM v3) with Python? I found this code below on wilmott.com and it works just fine, but it's for the old API version.</p>
  
  <p>Does anyone know the corresponding code for the new version?</p>
  
  <pre><code>from win32com.client import DispatchWithEvents
  from pythoncom import PumpWaitingMessages, Empty, Missing
  from time import time
  
  class BBCommEvent:
      def OnData(self, Security, cookie, Fields, Data, Status):
          print 'OnData: ' + `Data`
  
      def OnStatus(self, Status, SubStatus, StatusDescription):
          print 'OnStatus'
  
  class TestAsync:
      def __init__(self):
          clsid = '{F2303261-4969-11D1-B305-00805F815CBF}'
          progid = 'Bloomberg.Data.1'
  
          print 'connecting to BBComm'        
          blp = DispatchWithEvents(clsid, BBCommEvent)
          blp.AutoRelease = False
          blp.Subscribe('EUR Curncy', 1, 'LAST_PRICE', Results = Empty)
          blp.Flush()
  
          end_time = time() + 5
  
          while 1:
              PumpWaitingMessages()
              if end_time &lt; time():
                  print 'timed out'
                  break
  
  if __name__ == "__main__":
      ta = TestAsync()
  </code></pre>