betcode-org/flumine

datetime patching bug

liampauling opened this issue · 0 comments

The current simulation code patches datetime.datetime here this works for any import of datetime but fails on any modules that have already imported the datetime class via from datetime import datetime

import datetime
from datetime import datetime as dt

datetime.datetime.utcnow() == config.publish_time
dt.utcnow() != config.pubish_time

In order to do this each module needs to be cycled and patched accordingly as well as being unpatched on exit, the freezegun library does something similar with this scary code