Select to view content in your preferred language

How to check if concurrent or single-use licence borrowed using python

288
1
04-18-2023 04:44 PM
erinheinrich
New Contributor III

Hi,

Since ArcPro 3.0, my python scripts using multiprocessing will only work if I have a single-use licence setup on the machine - previously concurrent licence worked fine, but no longer.

Is there any way to check in python if machine is single-use licenced or concurrent? I want script to end if not single-use, as process takes days otherwise (an no error is thrown)...

I have googled and can't come up with anything.

Thanks, 

Erin

0 Kudos
1 Reply
by Anonymous User
Not applicable

This is a headscratcher. Looks like the script is essentially creating more instances of the application/arcpy when it runs, but since you only have one available license it fails. I don't think there is a built in check either.

Could you get with your admin(?) and do one of the following:

  • Sign me in automatically is checked when signing in to ArcGIS Pro.
  • ArcGIS Pro has been authorized to work offline.
  • ArcGIS Pro is configured with a Concurrent Use license and at least one license is available on the ArcGIS License Manager.

As a work around, you could maybe pass the licensed arcpy module to workers (as much as the pickling will let you):

 

 

import sys
import arcpy
import multiprocessing as mp


arcpy.env.workspace = "c:/data/world.gdb"

def package_pass(module, int):
    line = None
    if module("ArcInfo") == "Available":
        # arcpy.PolygonToLine_management("Lakes", "LakeLines")
        line = f'Licensed {int}'
    else:
        line = 'Not licensed'
    return line

if __name__ == '__main__':
    with mp.Pool(processes=2) as pool:
        jobs = []
    
        for k in range(10):
            jobs.append(pool.apply_async(package_pass, (arcpy.CheckProduct, k)))

        res = [j.get() for j in jobs]

        for r in res:
            print(r)

 

 

 

0 Kudos