MCPcopy Index your code
hub / github.com/pgadmin-org/pgadmin4 / list

Method list

web/pgadmin/misc/bgprocess/processes.py:734–793  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

732
733 @staticmethod
734 def list():
735 processes = Process.for_user()
736 changed = False
737
738 browser_preference = Preferences.module('browser')
739 expiry_add = timedelta(
740 browser_preference.preference('process_retain_days').get() or 1
741 )
742
743 res = []
744 for p in [*processes]:
745 if p.start_time is not None:
746 # remove expired jobs
747 process_expiration_time = \
748 parser.parse(p.start_time) + expiry_add
749 if datetime.now(process_expiration_time.tzinfo) >= \
750 process_expiration_time:
751 shutil.rmtree(p.logdir, True)
752 db.session.delete(p)
753 changed = True
754
755 status, updated = BatchProcess.update_process_info(p)
756 if not status:
757 continue
758 elif not changed:
759 changed = updated
760
761 if p.start_time is None or (
762 p.acknowledge is not None and p.end_time is None
763 ):
764 continue
765
766 stime = parser.parse(p.start_time)
767 etime = parser.parse(p.end_time or get_current_time())
768
769 execution_time = BatchProcess.total_seconds(etime - stime)
770
771 desc, details, type_desc, current_storage_dir = BatchProcess.\
772 _check_process_desc(p)
773
774 res.append({
775 'id': p.pid,
776 'desc': desc,
777 'type_desc': type_desc,
778 'details': details,
779 'stime': stime,
780 'etime': p.end_time,
781 'exit_code': p.exit_code,
782 'acknowledge': p.acknowledge,
783 'execution_time': execution_time,
784 'process_state': p.process_state,
785 'utility_pid': p.utility_pid,
786 'server_id': p.server_id,
787 'current_storage_dir': current_storage_dir,
788 })
789
790 if changed:
791 db.session.commit()

Callers 10

get_permissionsMethod · 0.45
list_subscriptionsMethod · 0.45
list_resource_groupsMethod · 0.45
get_projectsMethod · 0.45
get_regionsMethod · 0.45
get_instance_typesMethod · 0.45
get_database_versionsMethod · 0.45
indexFunction · 0.45
upgradeFunction · 0.45

Calls 10

for_userMethod · 0.80
moduleMethod · 0.80
preferenceMethod · 0.80
update_process_infoMethod · 0.80
total_secondsMethod · 0.80
_check_process_descMethod · 0.80
appendMethod · 0.80
get_current_timeFunction · 0.70
getMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected