@@ -10,7 +10,7 @@ import Graph from './graph/graph';
10
10
import EdgeManager from './edge_manager' ;
11
11
import _ from 'lodash' ;
12
12
import QEdge2APIEdgeHandler from './qedge2apiedge' ;
13
- import { LogEntry , StampedLog } from '@biothings-explorer/utils' ;
13
+ import { lockWithActionAsync , LogEntry , StampedLog } from '@biothings-explorer/utils' ;
14
14
import { promises as fs } from 'fs' ;
15
15
import { getDescendants } from '@biothings-explorer/node-expansion' ;
16
16
import { resolveSRI , SRINodeNormFailure } from 'biomedical_id_resolver' ;
@@ -81,8 +81,11 @@ export default class TRAPIQueryHandler {
81
81
if ( this . options . smartapi ) {
82
82
smartapiRegistry = this . options . smartapi ;
83
83
} else {
84
- const file = await fs . readFile ( this . path , 'utf-8' ) ;
85
- smartapiRegistry = JSON . parse ( file ) ;
84
+ smartapiRegistry = await lockWithActionAsync ( [ this . path ] , async ( ) => {
85
+ const file = await fs . readFile ( this . path , 'utf-8' ) ;
86
+ const hits = JSON . parse ( file ) ;
87
+ return hits ;
88
+ } , debug ) ;
86
89
}
87
90
88
91
const smartapiIds : string [ ] = [ ] ;
@@ -124,7 +127,7 @@ export default class TRAPIQueryHandler {
124
127
125
128
const metaKG = new MetaKG ( this . path , this . predicatePath ) ;
126
129
debug ( `SmartAPI Specs read from path: ${ this . path } ` ) ;
127
- metaKG . constructMetaKGSync ( this . includeReasoner , this . options ) ;
130
+ await metaKG . constructMetaKGWithFileLock ( this . includeReasoner , this . options ) ;
128
131
return metaKG ;
129
132
}
130
133
@@ -722,7 +725,6 @@ export default class TRAPIQueryHandler {
722
725
return ;
723
726
}
724
727
debug ( 'MetaKG successfully loaded!' ) ;
725
-
726
728
span1 ?. finish ( ) ;
727
729
728
730
if ( global . missingAPIs ) {
0 commit comments