Closed PavMel closed 4 years ago
Thanks for providing so much detail, sorry to hear you are having issues.
I am taking a look at this at the moment. Have you been able to run the code successfully at all or does it always segfault?
Hi, Josh. Thank you for your comment. Time to time I didn't see any error.
It looks to be an issue with the objects being cleared up during garbage collection.
Can you try changing some of the scope to global like below and let me know how you get on.
import os
from collections import OrderedDict
from FiftyOneDegrees import fiftyone_degrees_mobile_detector_v3_wrapper
from fiftyone_degrees.mobile_detector.conf import
dataFile = os.path.join(ABSPATH, 'data', '51degrees', '51Degrees-PremiumV3_2.dat')
properties = settings.PROPERTIES
cacheSize = settings.CACHE_SIZE
poolSize = settings.POOL_SIZE
provider = None
def populate_db_init():
provider = fiftyone_degrees_mobile_detector_v3_wrapper.Provider(
dataFile,
properties,
cacheSize,
poolSize
)
profiles = provider.findProfiles("IsMob8ile", "True")
print("There are %d mobile profiles in the %s data file." % (profiles.getCount(), provider.getDataSetName()))
for profile_index in reversed(range(0, profiles.getCount())):
DeviceId = profiles.getProfileId(profile_index)
device_object = provider.getMatchForDeviceId("%s" % DeviceId)
item = OrderedDict([
('HardwareVendor', device_object.getValue('HardwareVendor')),
('HardwareModel', device_object.getValue('HardwareModel')),
('HardwareName', device_object.getValue('HardwareName') or None),
('HardwareFamily', device_object.getValue('HardwareFamily') or None),
('HardwareProfileSource', device_object.getValue('HardwareProfileSource') or None),
])
print(dict(item), profile_index)
return ### <<< HAPPENED HERE
if __name__ == '__main__':
populate_db_init()
I did it, but nothing changed.
Hi There
Apologies for the delay in getting back to you on this one. After further review we have managed to replicate the issue.
It was down to objects being destructed in the wrong order on some occasions. Please can you try the code below...
def populate_db_init():
import os
from collections import OrderedDict
from FiftyOneDegrees import fiftyone_degrees_mobile_detector_v3_wrapper
from fiftyone_degrees.mobile_detector.conf import settings
dataFile = '../../data/51Degrees-EnterpriseV3.2.dat'
properties = settings.PROPERTIES
cacheSize = settings.CACHE_SIZE
poolSize = settings.POOL_SIZE
provider = fiftyone_degrees_mobile_detector_v3_wrapper.Provider(
dataFile,
properties,
cacheSize,
poolSize
)
profiles = provider.findProfiles("IsMobile", "True")
print("There are %d mobile profiles in the %s data file." % (profiles.getCount(), provider.getDataSetName()))
for profile_index in reversed(range(0, profiles.getCount())):
DeviceId = profiles.getProfileId(profile_index)
device_object = provider.getMatchForDeviceId("%s" % DeviceId)
item = OrderedDict([
('HardwareVendor', device_object.getValue('HardwareVendor')),
('HardwareModel', device_object.getValue('HardwareModel')),
('HardwareName', device_object.getValue('HardwareName') or None),
('HardwareFamily', device_object.getValue('HardwareFamily') or None),
('HardwareProfileSource', device_object.getValue('HardwareProfileSource') or None),
])
del device_object
print(dict(item), profile_index)
del provider
return ### <<< HAPPENED HERE
if __name__ == '__main__':
populate_db_init()
fixed, closed
Hi, there. Thank you for your very nice job. This is report for you: Python libs has been Installed from source from master branch. But version from pypi affected too.
Code:
Log: