Previously is was thought that blpapi.CorrelationIds need to be unique to a blpapi.Session, however this is not true.
When subscribing or requesting information an application has
the choice of providing a CorrelationId they construct
themselves or allowing the session to construct one for
them. If the application supplies a CorrelationId it must not
re-use the value contained in it in another CorrelationId
whilst the original request or subscription is still active.
An example shows this
import blpapi
import time
session = blpapi.Session()
session.start()
session.openService("//blp/refdata")
service = session.getService("//blp/refdata")
cid = blpapi.CorrelationId(1)
request = service.createRequest("ReferenceDataRequest")
request.getElement("securities").appendValue("IBM US Equity")
request.getElement("fields").appendValue("PX_LAST")
# same cid provided orginal request is not active is fine
session.sendRequest(request, correlationId=cid)
time.sleep(2)
session.sendRequest(request, correlationId=cid)
# same cid immediately causes errors
session.sendRequest(request, correlationId=cid)
session.sendRequest(request, correlationId=cid)
DuplicateCorrelationIdException: Duplicate correlation id: [ valueType=INT classId=0 value=1 ] (0x00020005)
The restart() method was provided as a hack to avoid managing correlationIds throughout the lifetime of a session. As shown above, this is unnecessary and has several limitations, particularly is we desire to extend the functionality such that the user can pass in a custom session directly.
Previously is was thought that
blpapi.CorrelationId
s need to be unique to ablpapi.Session
, however this is not true.An example shows this
The
restart()
method was provided as a hack to avoid managingcorrelationId
s throughout the lifetime of a session. As shown above, this is unnecessary and has several limitations, particularly is we desire to extend the functionality such that the user can pass in a customsession
directly.