You want to do this with the ArcGIS api for python?
ArcMap? or ArcGIS Pro?
Why a spatial join when other options exist?
As a start, I would intersect the polyline featureclass with the polygon featureclass (returning polylines).
Intersect—Help | ArcGIS Desktop
keep the attributes of both and you can query the shapelength field of the new file for those values greater than your threshold distance.