@@ -360,7 +360,7 @@ def desc(self):
360360 )
361361
362362
363- class PyPIAttestationAvailableCheck (NetworkCheck ):
363+ class PyPIAttestationAvailableCheck (_UrlCheck ):
364364 """Check for available PyPI attestations."""
365365
366366 required_addons = (addons .UseAddon ,)
@@ -396,40 +396,6 @@ def _provenance_check(self, filename, url, *, pkg):
396396 result = PyPIAttestationAvailable (filename , pkg = pkg )
397397 return result
398398
399- def task_done (self , pkg , filename , future ):
400- """Determine the result of a given URL verification task."""
401- exc = future .exception ()
402- if exc is not None :
403- # traceback can't be pickled so serialize it
404- tb = traceback .format_exc ()
405- # return exceptions that occurred in threads
406- self .results_q .put (tb )
407- return
408-
409- result = future .result ()
410- if result is not None :
411- if pkg is not None :
412- # recreate result object with different pkg target and attr
413- attrs = result ._attrs .copy ()
414- attrs ["filename" ] = filename
415- result = result ._create (** attrs , pkg = pkg )
416- self .results_q .put ([result ])
417-
418- def _schedule_check (self , filename , url , executor , futures , ** kwargs ):
419- """Schedule verification method to run in a separate thread against a given URL.
420-
421- Note that this tries to avoid hitting the network for the same URL
422- twice using a mapping from requested URLs to future objects, adding
423- result-checking callbacks to the futures of existing URLs.
424- """
425- future = futures .get (url )
426- if future is None :
427- future = executor .submit (self ._provenance_check , filename , url , ** kwargs )
428- future .add_done_callback (partial (self .task_done , None , None ))
429- futures [url ] = future
430- else :
431- future .add_done_callback (partial (self .task_done , kwargs ["pkg" ], filename ))
432-
433399 def _get_urls (self , pkg ):
434400 # ignore conditionals
435401 fetchables , _ = self .fetch_filter (
@@ -464,7 +430,7 @@ def schedule(self, pkg, executor, futures):
464430 return
465431
466432 for filename , url in self ._get_urls (pkg ):
467- self ._schedule_check (filename , url , executor , futures , pkg = pkg )
433+ self ._schedule_check (self . _provenance_check , filename , url , executor , futures , pkg = pkg )
468434
469435
470436class DetachedSignatureAvailable (results .VersionResult , results .Info ):
0 commit comments